/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* lvds panel driver.
* specified in linux/Documentation/devicetree/bindings/display/panel/
* Simple RGB panels could be added as well
* registers an endpoint for use by graphic controller drivers
*
*/
if (of_getprop_uint32(phandle, "width-mm", &sc->sc_panel.panel_width) ||
of_getprop_uint32(phandle, "height-mm", &sc->sc_panel.panel_height)){
aprint_error(": missing width-mm or height-mm properties\n");
return;
}
for (child = OF_child(phandle); child; child = OF_peer(child)) {
if (OF_getprop(child, "name", buf, sizeof(buf)) <= 0)
continue;
if (strcmp(buf, "panel-timing") != 0)
continue;
if (display_timing_parse(child,
&sc->sc_panel.panel_timing) != 0) {
aprint_error(": failed to parse panel-timing\n");
return;
}
}
if (sc->sc_panel.panel_timing.clock_freq == 0) {
aprint_error(": missing panel-timing\n");
return;
}
switch(sc->sc_panel.panel_type) {
case PANEL_LVDS:
case PANEL_DUAL_LVDS:
val = fdtbus_get_string(phandle, "data-mapping");
if (val == NULL) {
aprint_error(": missing data-mapping\n");
return;
}
if (strcmp(val, "jeida-18") == 0)
sc->sc_panel.panel_lvds_format = LVDS_JEIDA_18;
else if (strcmp(val, "jeida-24") == 0)
sc->sc_panel.panel_lvds_format = LVDS_JEIDA_24;
else if (strcmp(val, "vesa-24") == 0)
sc->sc_panel.panel_lvds_format = LVDS_VESA_24;
else {
aprint_error(": unknown data-mapping \"%s\"\n", val);
return;
}
break;
default:
panic("unknown panel type %d", sc->sc_panel.panel_type);
}
aprint_naive("\n");
aprint_normal(": %dx%d", timing->hactive, timing->vactive);
switch(sc->sc_panel.panel_type) {
case PANEL_LVDS:
aprint_normal(" LVDS");
break;
case PANEL_DUAL_LVDS:
aprint_normal(" dual-link LVDS");
break;
default:
panic(" unknown panel type %d", sc->sc_panel.panel_type);
}
aprint_normal(" panel\n");
for (i = 0; i < MAX_GPIO_ENABLES ; i++) {
sc->sc_gpios_enable[i] = fdtbus_gpio_acquire_index(phandle,
"enable-gpios", i, GPIO_PIN_OUTPUT);
if (sc->sc_gpios_enable[i] == NULL)
break;
}
aprint_verbose_dev(self, "%d enable GPIO%c\n", i, i > 1 ? 's' : ' ');