/dts-v1/;
/plugin/;

/ {
  compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

  /* PWM0 function */
  fragment@0 {
    target = <&gpio>;
    __overlay__ {
      pwm_pins: pwm_pins {
        brcm,pins = <12>;
        brcm,function = <4>; /* Alt1 */
      };
    };
  };

  fragment@1 {
    target = <&pwm>;
    __overlay__ {
      pinctrl-names = "default";
      pinctrl-0 = <&pwm_pins>;
      assigned-clock-rates = <100000000>;
      status = "okay";
    };
  };

  fragment@2 {
    target-path = "/";

    __overlay__ {
      /* Panel backlight through PWM0 on GPIO 12 */
      backlight_lvds: backlight {
        compatible = "pwm-backlight";
        pwms = <&pwm 0 5000000>; /* Period of 5000000ns means 200Hz */
        brightness-levels = <0  1000>;
        num-interpolated-steps = <1000>;
        default-brightness-level = <800>;
        enable-gpios = <&gpio 17 0>; /* Backlight enable... */
      };

      panel: panel {
        compatible = "innolux,n125hce-gn1", "simple-panel";
        backlight = <&backlight_lvds>;
        no-hpd;
        port {
          panel_in: endpoint {
            remote-endpoint = <&edp_bridge_out>;
          };
        };
      };
    };
  };

  fragment@3 {
    target = <&i2c0>;
    __overlay__ {
      status = "okay";

      // DSI to eDP converter on motherboard
      edp_bridge: sn65dsi86@2c {
        compatible = "ti,sn65dsi86";
        reg = <0x2c>;
        enable-gpios = <&gpio 8 0>;

        ports {
          #address-cells = <1>;
          #size-cells = <0>;

          port@0 {
            reg = <0>;

            edp_bridge_in: endpoint {
              remote-endpoint = <&mipi_dsi_out>;
            };
          };

          port@1 {
            reg = <1>;

            edp_bridge_out: endpoint {
              remote-endpoint = <&panel_in>;
            };
          };
        };
      };
    };
  };

  fragment@4 {
    target = <&dsi1>;
    __overlay__ {

      status = "okay";

      #address-cells = <1>;
      #size-cells = <0>;

      port {
        mipi_dsi_out: endpoint {
          remote-endpoint = <&edp_bridge_in>;
        };
      };
    };
  };
};