aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ubicom32/files/drivers/video/backlight
diff options
context:
space:
mode:
authorblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
committerblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
commit5c105d9f3fd086aff195d3849dcf847d6b0bd927 (patch)
tree1229a11f725bfa58aa7c57a76898553bb5f6654a /target/linux/ubicom32/files/drivers/video/backlight
downloadopenwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.tar.gz
openwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.zip
branch Attitude Adjustment
git-svn-id: svn://svn.openwrt.org/openwrt/branches/attitude_adjustment@33625 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ubicom32/files/drivers/video/backlight')
-rw-r--r--target/linux/ubicom32/files/drivers/video/backlight/ubicom32bl.c399
-rw-r--r--target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.c372
-rw-r--r--target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.h546
-rw-r--r--target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcdpower.c194
4 files changed, 1511 insertions, 0 deletions
diff --git a/target/linux/ubicom32/files/drivers/video/backlight/ubicom32bl.c b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32bl.c
new file mode 100644
index 000000000..99538c341
--- /dev/null
+++ b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32bl.c
@@ -0,0 +1,399 @@
+/*
+ * drivers/video/backlight/ubicom32bl.c
+ * Backlight driver for the Ubicom32 platform
+ *
+ * (C) Copyright 2009, Ubicom, Inc.
+ *
+ * This file is part of the Ubicom32 Linux Kernel Port.
+ *
+ * The Ubicom32 Linux Kernel Port is free software: you can redistribute
+ * it and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Ubicom32 Linux Kernel Port is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the Ubicom32 Linux Kernel Port. If not,
+ * see <http://www.gnu.org/licenses/>.
+ *
+ * Ubicom32 implementation derived from (with many thanks):
+ * arch/m68knommu
+ * arch/blackfin
+ * arch/parisc
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/backlight.h>
+#include <linux/fb.h>
+
+#include <asm/ubicom32bl.h>
+#include <asm/ip5000.h>
+
+#define DRIVER_NAME "ubicom32bl"
+#define UBICOM32BL_MAX_BRIGHTNESS 255
+
+struct ubicom32bl_data {
+ /*
+ * Pointer to the platform data structure. Keep this around since we need values
+ * from it to set the backlight intensity.
+ */
+ const struct ubicom32bl_platform_data *pdata;
+
+ /*
+ * Backlight device, we have to save this for use when we remove ourselves.
+ */
+ struct backlight_device *bldev;
+
+ /*
+ * Current intensity, used for get_intensity.
+ */
+ int cur_intensity;
+
+ /*
+ * Init function for PWM
+ */
+ int (*init_fn)(struct ubicom32bl_data *);
+
+ /*
+ * Set intensity function depending on the backlight type
+ */
+ int (*set_intensity_fn)(struct ubicom32bl_data *, int);
+};
+
+/*
+ * ubicom32bl_set_intensity_gpio
+ */
+static int ubicom32bl_set_intensity_gpio(struct ubicom32bl_data *ud, int intensity)
+{
+ ud->cur_intensity = intensity ? 255 : 0;
+
+ if (intensity) {
+ // set gpio
+ return 0;
+ }
+
+ // clear gpio
+ return 0;
+}
+
+/*
+ * ubicom32bl_set_intensity_hw
+ */
+static int ubicom32bl_set_intensity_hw(struct ubicom32bl_data *ud, int intensity)
+{
+ u16_t period = ud->pdata->pwm_period;
+ u16_t duty;
+
+ /*
+ * Calculate the new duty cycle
+ */
+ duty = (period * intensity) / (UBICOM32BL_MAX_BRIGHTNESS + 1);
+
+ /*
+ * Set the new duty cycle
+ */
+ switch (ud->pdata->pwm_channel) {
+ case 0:
+ /*
+ * Channel 0 is in the lower half of PORT C ctl0 and ctl1
+ */
+ UBICOM32_IO_PORT(RC)->ctl1 = (ud->pdata->pwm_period << 16) | duty;
+ break;
+
+ case 1:
+ /*
+ * Channel 1 is in the upper half of PORT C ctl0 and ctl2
+ */
+ UBICOM32_IO_PORT(RC)->ctl2 = (ud->pdata->pwm_period << 16) | duty;
+ break;
+
+ case 2:
+ /*
+ * Channel 2 is in PORT H ctl0 and ctl1
+ */
+ UBICOM32_IO_PORT(RH)->ctl1 = (ud->pdata->pwm_period << 16) | duty;
+ break;
+ }
+
+ ud->cur_intensity = intensity;
+
+ return 0;
+}
+
+/*
+ * ubicom32bl_set_intensity
+ */
+static int ubicom32bl_set_intensity(struct backlight_device *bd)
+{
+ struct ubicom32bl_data *ud = (struct ubicom32bl_data *)bl_get_data(bd);
+ int intensity = bd->props.brightness;
+
+ /*
+ * If we're blanked the the intensity doesn't matter.
+ */
+ if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
+ intensity = 0;
+ }
+
+ /*
+ * Check for inverted backlight.
+ */
+ if (ud->pdata->invert) {
+ intensity = UBICOM32BL_MAX_BRIGHTNESS - intensity;
+ }
+
+ if (ud->set_intensity_fn) {
+ return ud->set_intensity_fn(ud, intensity);
+ }
+
+ return -ENXIO;
+}
+
+/*
+ * ubicom32bl_get_intensity
+ * Return the current intensity of the backlight.
+ */
+static int ubicom32bl_get_intensity(struct backlight_device *bd)
+{
+ struct ubicom32bl_data *ud = (struct ubicom32bl_data *)bl_get_data(bd);
+
+ return ud->cur_intensity;
+}
+
+/*
+ * ubicom32bl_init_hw_pwm
+ * Set the appropriate PWM registers
+ */
+static int ubicom32bl_init_hw_pwm(struct ubicom32bl_data *ud)
+{
+ /*
+ * bit 13: enable
+ */
+ u16_t pwm_cfg = (1 << 13) | (ud->pdata->pwm_prescale << 8) ;
+
+ switch (ud->pdata->pwm_channel) {
+ case 0:
+ /*
+ * Channel 0 is in the lower half of PORT C ctl0 and ctl1 (PA5)
+ */
+ UBICOM32_IO_PORT(RC)->ctl0 &= ~0xFFFF;
+ UBICOM32_IO_PORT(RC)->ctl0 |= pwm_cfg;
+ UBICOM32_IO_PORT(RC)->ctl1 = ud->pdata->pwm_period << 16;
+
+ /*
+ * If the port function is not set, set it to GPIO/PWM
+ */
+ if (!UBICOM32_IO_PORT(RA)->function) {
+ UBICOM32_IO_PORT(RA)->function = 3;
+ }
+ break;
+
+ case 1:
+ /*
+ * Channel 1 is in the upper half of PORT C ctl0 and ctl2 (PE4)
+ */
+ UBICOM32_IO_PORT(RC)->ctl0 &= ~0xFFFF0000;
+ UBICOM32_IO_PORT(RC)->ctl0 |= (pwm_cfg << 16);
+ UBICOM32_IO_PORT(RC)->ctl2 = ud->pdata->pwm_period << 16;
+
+ /*
+ * If the port function is not set, set it to GPIO/ExtIOInt
+ */
+ if (!UBICOM32_IO_PORT(RE)->function) {
+ UBICOM32_IO_PORT(RE)->function = 3;
+ }
+ break;
+
+ case 2:
+ /*
+ * Channel 2 is in PORT H ctl0 and ctl1 (PD0)
+ */
+ UBICOM32_IO_PORT(RH)->ctl0 &= ~0xFFFF0000;
+ UBICOM32_IO_PORT(RH)->ctl0 = pwm_cfg;
+ UBICOM32_IO_PORT(RH)->ctl1 = ud->pdata->pwm_period << 16;
+
+ /*
+ * If the port function is not set, set it to GPIO
+ */
+ if (!UBICOM32_IO_PORT(RD)->function) {
+ UBICOM32_IO_PORT(RD)->function = 3;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/*
+ * ubicom32bl_init_gpio
+ * Allocate the appropriate GPIO
+ */
+static int ubicom32bl_init_gpio(struct ubicom32bl_data *ud)
+{
+ return 0;
+}
+
+static struct backlight_ops ubicom32bl_ops = {
+ .get_brightness = ubicom32bl_get_intensity,
+ .update_status = ubicom32bl_set_intensity,
+};
+
+/*
+ * ubicom32bl_probe
+ */
+static int ubicom32bl_probe(struct platform_device *pdev)
+{
+ const struct ubicom32bl_platform_data *pdata = pdev->dev.platform_data;
+ struct ubicom32bl_data *ud;
+ struct backlight_device *bldev;
+ int retval;
+
+ /*
+ * Check to see if we have any platform data, if we don't then the backlight is not
+ * configured on this device.
+ */
+ if (!pdata) {
+ return -ENODEV;
+ }
+
+ /*
+ * Allocate our private data
+ */
+ ud = kzalloc(sizeof(struct ubicom32bl_data), GFP_KERNEL);
+ if (!ud) {
+ return -ENOMEM;
+ }
+
+ ud->pdata = pdata;
+
+ /*
+ * Check to see that the platform data is valid for this driver
+ */
+ switch (pdata->type) {
+ case UBICOM32BL_TYPE_PWM:
+ {
+ /*
+ * Make sure we have a PWM peripheral
+ */
+ u32_t chipid;
+ asm volatile (
+ "move.4 %0, CHIP_ID \n\t"
+ : "=r" (chipid)
+ );
+ if (chipid != 0x00030001) {
+ retval = -ENODEV;
+ goto fail;
+ }
+
+ if (pdata->pwm_channel > 3) {
+ retval = -ENODEV;
+ goto fail;
+ }
+ if (pdata->pwm_prescale > 16) {
+ retval = -EINVAL;
+ goto fail;
+ }
+
+ ud->init_fn = ubicom32bl_init_hw_pwm;
+ ud->set_intensity_fn = ubicom32bl_set_intensity_hw;
+ break;
+ }
+
+ case UBICOM32BL_TYPE_PWM_HRT:
+ // For now, PWM HRT devices are treated as binary lights.
+
+ case UBICOM32BL_TYPE_BINARY:
+ ud->init_fn = ubicom32bl_init_gpio;
+ ud->set_intensity_fn = ubicom32bl_set_intensity_gpio;
+ break;
+ }
+
+ /*
+ * Register our backlight device
+ */
+ bldev = backlight_device_register(DRIVER_NAME, &pdev->dev, ud, &ubicom32bl_ops);
+ if (IS_ERR(bldev)) {
+ retval = PTR_ERR(bldev);
+ goto fail;
+ }
+
+ ud->bldev = bldev;
+ ud->cur_intensity = pdata->default_intensity;
+ platform_set_drvdata(pdev, ud);
+
+ /*
+ * Start up the backlight at the prescribed default intensity
+ */
+ bldev->props.power = FB_BLANK_UNBLANK;
+ bldev->props.max_brightness = UBICOM32BL_MAX_BRIGHTNESS;
+ bldev->props.brightness = pdata->default_intensity;
+
+ if (ud->init_fn) {
+ if (ud->init_fn(ud) != 0) {
+ retval = -ENODEV;
+ backlight_device_unregister(ud->bldev);
+ goto fail;
+ }
+ }
+ ubicom32bl_set_intensity(bldev);
+
+ printk(KERN_INFO DRIVER_NAME ": Backlight driver started\n");
+
+ return 0;
+
+fail:
+ platform_set_drvdata(pdev, NULL);
+ kfree(ud);
+ return retval;
+}
+
+/*
+ * ubicom32bl_remove
+ */
+static int __exit ubicom32bl_remove(struct platform_device *pdev)
+{
+ struct ubicom32bl_data *ud = platform_get_drvdata(pdev);
+
+ backlight_device_unregister(ud->bldev);
+ platform_set_drvdata(pdev, NULL);
+ kfree(ud);
+
+ return 0;
+}
+
+static struct platform_driver ubicom32bl_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+
+ .remove = __exit_p(ubicom32bl_remove),
+};
+
+/*
+ * ubicom32bl_init
+ */
+static int __init ubicom32bl_init(void)
+{
+ return platform_driver_probe(&ubicom32bl_driver, ubicom32bl_probe);
+}
+module_init(ubicom32bl_init);
+
+/*
+ * ubicom32bl_exit
+ */
+static void __exit ubicom32bl_exit(void)
+{
+ platform_driver_unregister(&ubicom32bl_driver);
+}
+module_exit(ubicom32bl_exit);
+
+MODULE_AUTHOR("Patrick Tjin <@ubicom.com>");
+MODULE_DESCRIPTION("Ubicom32 backlight driver");
+MODULE_LICENSE("GPL");
diff --git a/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.c b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.c
new file mode 100644
index 000000000..e4f8c713e
--- /dev/null
+++ b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.c
@@ -0,0 +1,372 @@
+/*
+ * drivers/video/ubicom32lcd.c
+ * LCD initilization code
+ *
+ * (C) Copyright 2009, Ubicom, Inc.
+ *
+ * This file is part of the Ubicom32 Linux Kernel Port.
+ *
+ * The Ubicom32 Linux Kernel Port is free software: you can redistribute
+ * it and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Ubicom32 Linux Kernel Port is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the Ubicom32 Linux Kernel Port. If not,
+ * see <http://www.gnu.org/licenses/>.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+
+#include <asm/ip5000.h>
+#include <asm/gpio.h>
+#include <asm/ubicom32lcd.h>
+
+#include "ubicom32lcd.h"
+
+#define DRIVER_NAME "ubicom32lcd"
+
+struct ubicom32lcd_data {
+ const struct ubicom32lcd_panel *panel;
+
+ int pin_cs;
+ int pin_rd;
+ int pin_rs;
+ int pin_wr;
+ int pin_reset;
+ struct ubicom32_io_port *port_data;
+ int data_shift;
+};
+
+/*
+ * ubicom32lcd_write
+ * Performs a write cycle on the bus (assumes CS asserted, RD & WR set)
+ */
+static void ubicom32lcd_write(struct ubicom32lcd_data *ud, int command, u16 data)
+{
+ if (command) {
+ UBICOM32_GPIO_SET_PIN_LOW(ud->pin_rs);
+ } else {
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rs);
+ }
+
+ asm volatile (
+ "or.4 4(%[port]), 4(%[port]), %[mask] \n\t"
+ "not.4 %[mask], %[mask] \n\t"
+ "and.4 8(%[port]), 8(%[port]), %[mask] \n\t"
+ "or.4 8(%[port]), 8(%[port]), %[cmd] \n\t"
+ :
+ : [port] "a" (ud->port_data),
+ [mask] "d" (0xFFFF << ud->data_shift),
+ [cmd] "d" (data << ud->data_shift)
+ : "cc"
+ );
+
+ UBICOM32_GPIO_SET_PIN_LOW(ud->pin_wr);
+
+ //ndelay(50);
+ udelay(1);
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_wr);
+
+ udelay(1);
+ //ndelay(50);
+}
+
+/*
+ * ubicom32lcd_read_data
+ * Performs a read cycle on the bus (assumes CS asserted, RD & WR set)
+ */
+static u16 ubicom32lcd_read_data(struct ubicom32lcd_data *ud)
+{
+ u32_t data;
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rs);
+
+ asm volatile (
+ "and.4 4(%[port]), 4(%[port]), %[mask]\n\t"
+ :
+ : [port] "a" (ud->port_data),
+ [mask] "d" (~(0xFFFF << ud->data_shift))
+ : "cc"
+ );
+
+ UBICOM32_GPIO_SET_PIN_LOW(ud->pin_rd);
+
+ ndelay(300);
+
+ asm volatile (
+ "lsr.4 %[data], 12(%[port]), %[shamt] \n\t"
+ "and.4 %[data], %[data], %[mask] \n\t"
+ : [data] "=d" (data)
+ : [port] "a" (ud->port_data),
+ [mask] "d" (0xFFFF),
+ [shamt] "d" (ud->data_shift)
+ : "cc"
+ );
+
+ ndelay(200);
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rd);
+
+ ndelay(500);
+
+ return data;
+}
+
+/*
+ * ubicom32lcd_execute
+ * Executes a script for performing operations on the LCD (assumes CS set)
+ */
+static void ubicom32lcd_execute(struct ubicom32lcd_data *ud, const struct ubicom32lcd_step *script)
+{
+ while (1) {
+ switch (script->op) {
+ case LCD_STEP_CMD:
+ ubicom32lcd_write(ud, 1, script->cmd);
+ break;
+
+ case LCD_STEP_DATA:
+ ubicom32lcd_write(ud, 0, script->data);
+ break;
+
+ case LCD_STEP_CMD_DATA:
+ ubicom32lcd_write(ud, 1, script->cmd);
+ ubicom32lcd_write(ud, 0, script->data);
+ break;
+
+ case LCD_STEP_SLEEP:
+ udelay(script->data);
+ break;
+
+ case LCD_STEP_DONE:
+ return;
+ }
+ script++;
+ }
+}
+
+/*
+ * ubicom32lcd_goto
+ * Places the gram pointer at a specific X, Y address
+ */
+static void ubicom32lcd_goto(struct ubicom32lcd_data *ud, int x, int y)
+{
+ ubicom32lcd_write(ud, 1, ud->panel->horz_reg);
+ ubicom32lcd_write(ud, 0, x);
+ ubicom32lcd_write(ud, 1, ud->panel->vert_reg);
+ ubicom32lcd_write(ud, 0, y);
+ ubicom32lcd_write(ud, 1, ud->panel->gram_reg);
+}
+
+/*
+ * ubicom32lcd_panel_init
+ * Initializes the lcd panel.
+ */
+static int ubicom32lcd_panel_init(struct ubicom32lcd_data *ud)
+{
+ u16 id;
+
+ UBICOM32_GPIO_SET_PIN_LOW(ud->pin_reset);
+ UBICOM32_GPIO_SET_PIN_OUTPUT(ud->pin_reset);
+ UBICOM32_GPIO_ENABLE(ud->pin_reset);
+
+ asm volatile (
+ "or.4 0x50(%[port]), 0x50(%[port]), %[mask] \n\t"
+ "not.4 %[mask], %[mask] \n\t"
+ "and.4 0x04(%[port]), 0x04(%[port]), %[mask] \n\t"
+ :
+ : [port] "a" (ud->port_data),
+ [mask] "d" (0xFFFF << ud->data_shift)
+ : "cc"
+ );
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rs);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rd);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_wr);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_cs);
+
+ UBICOM32_GPIO_SET_PIN_OUTPUT(ud->pin_rs);
+ UBICOM32_GPIO_SET_PIN_OUTPUT(ud->pin_rd);
+ UBICOM32_GPIO_SET_PIN_OUTPUT(ud->pin_wr);
+ UBICOM32_GPIO_SET_PIN_OUTPUT(ud->pin_cs);
+
+ UBICOM32_GPIO_ENABLE(ud->pin_rs);
+ UBICOM32_GPIO_ENABLE(ud->pin_rd);
+ UBICOM32_GPIO_ENABLE(ud->pin_wr);
+ UBICOM32_GPIO_ENABLE(ud->pin_cs);
+
+ udelay(20);
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_reset);
+
+ udelay(20);
+
+ UBICOM32_GPIO_SET_PIN_LOW(ud->pin_cs);
+
+ id = ubicom32lcd_read_data(ud);
+
+ /*
+ * We will try to figure out what kind of panel we have if we were not told.
+ */
+ if (!ud->panel) {
+ const struct ubicom32lcd_panel **p = ubicom32lcd_panels;
+ while (*p) {
+ if ((*p)->id && ((*p)->id == id)) {
+ break;
+ }
+ p++;
+ }
+ if (!*p) {
+ printk(KERN_WARNING DRIVER_NAME ":Could not find compatible panel, id=%x\n", id);
+ return -ENODEV;
+ }
+ ud->panel = *p;
+ }
+
+ /*
+ * Make sure panel ID matches if we were supplied a panel type
+ */
+ if (ud->panel->id && (ud->panel->id != id)) {
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_cs);
+
+ return -ENODEV;
+ }
+
+ ubicom32lcd_execute(ud, ud->panel->init_seq);
+
+ ubicom32lcd_goto(ud, 0, 0);
+
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_cs);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rd);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_wr);
+ UBICOM32_GPIO_SET_PIN_HIGH(ud->pin_rs);
+
+ printk(KERN_INFO DRIVER_NAME ": Initialized panel %s\n", ud->panel->desc);
+
+ return 0;
+}
+
+/*
+ * ubicom32lcd_probe
+ */
+static int ubicom32lcd_probe(struct platform_device *pdev)
+{
+ const struct ubicom32lcd_platform_data *pdata = pdev->dev.platform_data;
+ struct ubicom32lcd_data *ud;
+ int retval;
+
+ /*
+ * Allocate our private data
+ */
+ ud = kzalloc(sizeof(struct ubicom32lcd_data), GFP_KERNEL);
+ if (!ud) {
+ return -ENOMEM;
+ }
+
+ if (pdata) {
+ ud->pin_cs = pdata->pin_cs;
+ ud->pin_rd = pdata->pin_rd;
+ ud->pin_wr = pdata->pin_wr;
+ ud->pin_rs = pdata->pin_rs;
+ ud->pin_reset = pdata->pin_reset;
+ ud->port_data = pdata->port_data;
+ ud->data_shift = pdata->data_shift;
+ } else {
+ /*
+ * Defaults
+ */
+ ud->pin_cs = GPIO_RD_4;
+ ud->pin_rd = GPIO_RD_5;
+ ud->pin_rs = GPIO_RD_3;
+ ud->pin_wr = GPIO_RD_2;
+ ud->pin_reset = GPIO_RD_7;
+ ud->port_data = (struct ubicom32_io_port *)RI;
+ ud->data_shift = 0;
+ }
+
+ /*
+ * Initialize the display
+ */
+ retval = ubicom32lcd_panel_init(ud);
+ if (retval) {
+ kfree(ud);
+ return retval;
+ }
+
+ printk(KERN_INFO DRIVER_NAME ": LCD initialized\n");
+
+ return 0;
+}
+
+/*
+ * ubicom32lcd_remove
+ */
+static int __exit ubicom32lcd_remove(struct platform_device *pdev)
+{
+ struct ubicom32lcd_data *ud = platform_get_drvdata(pdev);
+
+ kfree(ud);
+
+ return 0;
+}
+
+static struct platform_driver ubicom32lcd_driver = {
+ .probe = ubicom32lcd_probe,
+ .remove = ubicom32lcd_remove,
+
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+
+ .remove = __exit_p(ubicom32lcd_remove),
+};
+
+static struct platform_device *ubicom32lcd_device;
+
+/*
+ * ubicom32lcd_init
+ */
+static int __init ubicom32lcd_init(void)
+{
+ int res;
+
+ res = platform_driver_register(&ubicom32lcd_driver);
+ if (res == 0) {
+ ubicom32lcd_device = platform_device_alloc(DRIVER_NAME, 0);
+ if (ubicom32lcd_device) {
+ res = platform_device_add(ubicom32lcd_device);
+ } else {
+ res = -ENOMEM;
+ }
+ if (res) {
+ platform_device_put(ubicom32lcd_device);
+ platform_driver_unregister(&ubicom32lcd_driver);
+ }
+ }
+ return res;
+}
+module_init(ubicom32lcd_init);
+
+/*
+ * ubicom32lcd_exit
+ */
+static void __exit ubicom32lcd_exit(void)
+{
+ platform_device_unregister(ubicom32lcd_device);
+ platform_driver_unregister(&ubicom32lcd_driver);
+}
+module_exit(ubicom32lcd_exit);
+
+MODULE_AUTHOR("Patrick Tjin <@ubicom.com>");
+MODULE_DESCRIPTION("Ubicom32 LCD driver");
+MODULE_LICENSE("GPL");
diff --git a/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.h b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.h
new file mode 100644
index 000000000..07650ba9e
--- /dev/null
+++ b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcd.h
@@ -0,0 +1,546 @@
+/*
+ * ubicom32lcd.h
+ * Ubicom32 lcd panel drivers
+ *
+ * (C) Copyright 2009, Ubicom, Inc.
+ *
+ * This file is part of the Ubicom32 Linux Kernel Port.
+ *
+ * This Ubicom32 library is free software: you can redistribute
+ * it and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Ubicom32 library is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the Ubicom32 Linux Kernel Port. If not,
+ * see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _UBICOM32LCD_H_
+#define _UBICOM32LCD_H_
+
+enum ubicom32lcd_op {
+ /*
+ * Sleep for (data) ms
+ */
+ LCD_STEP_SLEEP,
+
+ /*
+ * Execute write of command
+ */
+ LCD_STEP_CMD,
+
+ /*
+ * Execute write of data
+ */
+ LCD_STEP_DATA,
+
+ /*
+ * Execute write of command/data
+ */
+ LCD_STEP_CMD_DATA,
+
+ /*
+ * Script done
+ */
+ LCD_STEP_DONE,
+};
+
+struct ubicom32lcd_step {
+ enum ubicom32lcd_op op;
+ u16 cmd;
+ u16 data;
+};
+
+struct ubicom32lcd_panel {
+ const struct ubicom32lcd_step *init_seq;
+ const char *desc;
+
+ u32 xres;
+ u32 yres;
+ u32 stride;
+ u32 flags;
+
+ u16 id;
+ u16 horz_reg;
+ u16 vert_reg;
+ u16 gram_reg;
+};
+
+#ifdef CONFIG_LCD_UBICOM32_CFAF240320KTTS
+static const struct ubicom32lcd_step cfaf240320ktts_init_0[] = {
+ {LCD_STEP_CMD_DATA, 0x0001, 0x0000,}, // Driver Output Control Register (R01h) Page 14, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0700,}, // LCD Driving Waveform Control (R02h) Page 15, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0003, 0x50A0,}, // Entry Mode (R03h) 0 degrees
+ {LCD_STEP_CMD_DATA, 0x0004, 0x0000,}, // Scaling Control register (R04h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0008, 0x0207,}, // Display Control 2 (R08h) Page 17, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0009, 0x0000,}, // Display Control 3 (R09h) Page 18, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000A, 0x0000,}, // Frame Cycle Control (R0Ah) Page 19, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0000,}, // External Display Interface Control 1 (R0Ch) Page 20, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000D, 0x0000,}, // Frame Maker Position (R0Dh) Page 21, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000F, 0x0000,}, // External Display Interface Control 2 (R0Fh) Page 21, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0000,}, // Power Control 1 (R10h) Page 22, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x0007,}, // Power Control 2 (R11h) Page 23, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x0000,}, // Power Control 3 (R12h) Page 24, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0013, 0x0000,}, // Power Control 4 (R13h) Page 25, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 200},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0101,}, // Display Control (R07h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0010, 0x12B0,}, // Power Control 1 (R10h) Page 22, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x0007,}, // Power Control 2 (R11h) Page 23, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x01BB,}, // Power Control 3 (R12h) Page 24, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0013, 0x1300,}, // Power Control 4 (R13h) Page 25, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0029, 0x0010,}, // NVM read data 2 (R29h) Page 30, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0030, 0x000A,}, // Gamma Control 1 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0031, 0x1326,}, // Gamma Control 2 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0032, 0x0A29,}, // Gamma Control 3 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0033, 0x290A,}, // Gamma Control 4 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0034, 0x2613,}, // Gamma Control 5 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0035, 0x0A0A,}, // Gamma Control 6 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0036, 0x1E03,}, // Gamma Control 7 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0037, 0x031E,}, // Gamma Control 8 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0038, 0x0706,}, // Gamma Control 9 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0039, 0x0303,}, // Gamma Control 10 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003A, 0x0E04,}, // Gamma Control 11 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003B, 0x0E01,}, // Gamma Control 12 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003C, 0x010E,}, // Gamma Control 13 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003D, 0x040E,}, // Gamma Control 14 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003E, 0x0303,}, // Gamma Control 15 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003F, 0x0607,}, // Gamma Control 16 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0050, 0x0000,}, // Window Horizontal RAM Address Start (R50h) Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0051, 0x00EF,}, // Window Horizontal RAM Address End (R51h) Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0052, 0x0000,}, // Window Vertical RAM Address Start (R52h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0053, 0x013F,}, // Window Vertical RAM Address End (R53h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0060, 0x2700,}, // Driver Output Control (R60h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0061, 0x0001,}, // Driver Output Control (R61h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x006A, 0x0000,}, // Vertical Scroll Control (R6Ah) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0080, 0x0000,}, // Display Position - Partial Display 1 (R80h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0081, 0x0000,}, // RAM Address Start - Partial Display 1 (R81h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0082, 0x0000,}, // RAM Address End - Partial Display 1 (R82h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0083, 0x0000,}, // Display Position - Partial Display 2 (R83h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0084, 0x0000,}, // RAM Address Start - Partial Display 2 (R84h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0085, 0x0000,}, // RAM Address End - Partial Display 2 (R85h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0090, 0x0010,}, // Panel Interface Control 1 (R90h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0092, 0x0000,}, // Panel Interface Control 2 (R92h) Page 37, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0093, 0x0103,}, // Panel Interface control 3 (R93h) Page 38, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0095, 0x0210,}, // Panel Interface control 4 (R95h) Page 38, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0097, 0x0000,}, // Panel Interface Control 5 (R97h) Page 40, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0098, 0x0000,}, // Panel Interface Control 6 (R98h) Page 41, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0173,}, // Display Control (R07h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel cfaf240320ktts_0 = {
+ .desc = "CFAF240320KTTS",
+ .init_seq = cfaf240320ktts_init_0,
+ .horz_reg = 0x20,
+ .vert_reg = 0x21,
+ .gram_reg = 0x22,
+ .xres = 240,
+ .yres = 320,
+ .stride = 240,
+ .id = 0x5408,
+};
+#endif
+
+#ifdef CONFIG_LCD_UBICOM32_CFAF240320KTTS_180
+static const struct ubicom32lcd_step cfaf240320ktts_init_180[] = {
+ {LCD_STEP_CMD_DATA, 0x0001, 0x0000,}, // Driver Output Control Register (R01h) Page 14, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0700,}, // LCD Driving Waveform Control (R02h) Page 15, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0003, 0x5000,}, // Entry Mode (R03h) 180 degrees
+ {LCD_STEP_CMD_DATA, 0x0004, 0x0000,}, // Scaling Control register (R04h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0008, 0x0207,}, // Display Control 2 (R08h) Page 17, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0009, 0x0000,}, // Display Control 3 (R09h) Page 18, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000A, 0x0000,}, // Frame Cycle Control (R0Ah) Page 19, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0000,}, // External Display Interface Control 1 (R0Ch) Page 20, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000D, 0x0000,}, // Frame Maker Position (R0Dh) Page 21, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x000F, 0x0000,}, // External Display Interface Control 2 (R0Fh) Page 21, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0000,}, // Power Control 1 (R10h) Page 22, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x0007,}, // Power Control 2 (R11h) Page 23, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x0000,}, // Power Control 3 (R12h) Page 24, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0013, 0x0000,}, // Power Control 4 (R13h) Page 25, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 200},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0101,}, // Display Control (R07h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0010, 0x12B0,}, // Power Control 1 (R10h) Page 22, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x0007,}, // Power Control 2 (R11h) Page 23, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x01BB,}, // Power Control 3 (R12h) Page 24, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0013, 0x1300,}, // Power Control 4 (R13h) Page 25, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0029, 0x0010,}, // NVM read data 2 (R29h) Page 30, SPFD5408B Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0030, 0x000A,}, // Gamma Control 1 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0031, 0x1326,}, // Gamma Control 2 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0032, 0x0A29,}, // Gamma Control 3 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0033, 0x290A,}, // Gamma Control 4 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0034, 0x2613,}, // Gamma Control 5 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0035, 0x0A0A,}, // Gamma Control 6 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0036, 0x1E03,}, // Gamma Control 7 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0037, 0x031E,}, // Gamma Control 8 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0038, 0x0706,}, // Gamma Control 9 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0039, 0x0303,}, // Gamma Control 10 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003A, 0x0E04,}, // Gamma Control 11 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003B, 0x0E01,}, // Gamma Control 12 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003C, 0x010E,}, // Gamma Control 13 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003D, 0x040E,}, // Gamma Control 14 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003E, 0x0303,}, // Gamma Control 15 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x003F, 0x0607,}, // Gamma Control 16 Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0050, 0x0000,}, // Window Horizontal RAM Address Start (R50h) Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0051, 0x00EF,}, // Window Horizontal RAM Address End (R51h) Page 32, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0052, 0x0000,}, // Window Vertical RAM Address Start (R52h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0053, 0x013F,}, // Window Vertical RAM Address End (R53h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0060, 0x2700,}, // Driver Output Control (R60h) Page 33, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0061, 0x0001,}, // Driver Output Control (R61h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x006A, 0x0000,}, // Vertical Scroll Control (R6Ah) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0080, 0x0000,}, // Display Position - Partial Display 1 (R80h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0081, 0x0000,}, // RAM Address Start - Partial Display 1 (R81h) Page 35, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0082, 0x0000,}, // RAM Address End - Partial Display 1 (R82h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0083, 0x0000,}, // Display Position - Partial Display 2 (R83h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0084, 0x0000,}, // RAM Address Start - Partial Display 2 (R84h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0085, 0x0000,}, // RAM Address End - Partial Display 2 (R85h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0090, 0x0010,}, // Panel Interface Control 1 (R90h) Page 36, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0092, 0x0000,}, // Panel Interface Control 2 (R92h) Page 37, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0093, 0x0103,}, // Panel Interface control 3 (R93h) Page 38, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0095, 0x0210,}, // Panel Interface control 4 (R95h) Page 38, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0097, 0x0000,}, // Panel Interface Control 5 (R97h) Page 40, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0098, 0x0000,}, // Panel Interface Control 6 (R98h) Page 41, SPFD5408B Datasheet
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0173,}, // Display Control (R07h) Page 16, SPFD5408B Datasheet
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel cfaf240320ktts_180 = {
+ .desc = "CFAF240320KTTS 180",
+ .init_seq = cfaf240320ktts_init_180,
+ .horz_reg = 0x20,
+ .vert_reg = 0x21,
+ .gram_reg = 0x22,
+ .xres = 240,
+ .yres = 320,
+ .stride = 240,
+ .id = 0x5408,
+};
+#endif
+
+#ifdef CONFIG_LCD_UBICOM32_TFT2N0369E_P
+static const struct ubicom32lcd_step tft2n0369ep_init[] = {
+ {LCD_STEP_CMD_DATA, 0x0028, 0x0006},
+ {LCD_STEP_CMD_DATA, 0x0000, 0x0001},
+ {LCD_STEP_SLEEP, 0, 15},
+ {LCD_STEP_CMD_DATA, 0x002B, 0x9532},
+ {LCD_STEP_CMD_DATA, 0x0003, 0xAAAC},
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0002},
+ {LCD_STEP_CMD_DATA, 0x000D, 0x000A},
+ {LCD_STEP_CMD_DATA, 0x000E, 0x2C00},
+ {LCD_STEP_CMD_DATA, 0x001E, 0x00AA},
+ {LCD_STEP_CMD_DATA, 0x0025, 0x8000},
+ {LCD_STEP_SLEEP, 0, 15},
+ {LCD_STEP_CMD_DATA, 0x0001, 0x2B3F},
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0600},
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0011, 0x6030},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0005, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0006, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0016, 0xEF1C},
+ {LCD_STEP_CMD_DATA, 0x0017, 0x0003},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0233},
+ {LCD_STEP_CMD_DATA, 0x000B, 0x5312},
+ {LCD_STEP_CMD_DATA, 0x000F, 0x0000},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0041, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0042, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0048, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0049, 0x013F},
+ {LCD_STEP_CMD_DATA, 0x0044, 0xEF00},
+ {LCD_STEP_CMD_DATA, 0x0045, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0046, 0x013F},
+ {LCD_STEP_CMD_DATA, 0x004A, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x004B, 0x0000},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0030, 0x0707},
+ {LCD_STEP_CMD_DATA, 0x0031, 0x0704},
+ {LCD_STEP_CMD_DATA, 0x0032, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0033, 0x0201},
+ {LCD_STEP_CMD_DATA, 0x0034, 0x0203},
+ {LCD_STEP_CMD_DATA, 0x0035, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0036, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0037, 0x0502},
+ {LCD_STEP_CMD_DATA, 0x003A, 0x0302},
+ {LCD_STEP_CMD_DATA, 0x003B, 0x0500},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0044, 239 << 8 | 0},
+ {LCD_STEP_CMD_DATA, 0x0045, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0046, 319},
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel tft2n0369ep = {
+ .desc = "TFT2N0369E-Portrait",
+ .init_seq = tft2n0369ep_init,
+ .horz_reg = 0x4e,
+ .vert_reg = 0x4f,
+ .gram_reg = 0x22,
+ .xres = 240,
+ .yres = 320,
+ .stride = 240,
+ .id = 0x8989,
+};
+#endif
+
+#ifdef CONFIG_LCD_UBICOM32_TFT2N0369E_L
+static const struct ubicom32lcd_step tft2n0369e_init[] = {
+ {LCD_STEP_CMD_DATA, 0x0028, 0x0006},
+ {LCD_STEP_CMD_DATA, 0x0000, 0x0001},
+ {LCD_STEP_SLEEP, 0, 15},
+ {LCD_STEP_CMD_DATA, 0x002B, 0x9532},
+ {LCD_STEP_CMD_DATA, 0x0003, 0xAAAC},
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0002},
+ {LCD_STEP_CMD_DATA, 0x000D, 0x000A},
+ {LCD_STEP_CMD_DATA, 0x000E, 0x2C00},
+ {LCD_STEP_CMD_DATA, 0x001E, 0x00AA},
+ {LCD_STEP_CMD_DATA, 0x0025, 0x8000},
+ {LCD_STEP_SLEEP, 0, 15},
+ {LCD_STEP_CMD_DATA, 0x0001, 0x2B3F},
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0600},
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0011, 0x60A8},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0005, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0006, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0016, 0xEF1C},
+ {LCD_STEP_CMD_DATA, 0x0017, 0x0003},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0233},
+ {LCD_STEP_CMD_DATA, 0x000B, 0x5312},
+ {LCD_STEP_CMD_DATA, 0x000F, 0x0000},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0041, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0042, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0048, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0049, 0x013F},
+ {LCD_STEP_CMD_DATA, 0x0044, 0xEF00},
+ {LCD_STEP_CMD_DATA, 0x0045, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0046, 0x013F},
+ {LCD_STEP_CMD_DATA, 0x004A, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x004B, 0x0000},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0030, 0x0707},
+ {LCD_STEP_CMD_DATA, 0x0031, 0x0704},
+ {LCD_STEP_CMD_DATA, 0x0032, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0033, 0x0201},
+ {LCD_STEP_CMD_DATA, 0x0034, 0x0203},
+ {LCD_STEP_CMD_DATA, 0x0035, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0036, 0x0204},
+ {LCD_STEP_CMD_DATA, 0x0037, 0x0502},
+ {LCD_STEP_CMD_DATA, 0x003A, 0x0302},
+ {LCD_STEP_CMD_DATA, 0x003B, 0x0500},
+ {LCD_STEP_SLEEP, 0, 20},
+ {LCD_STEP_CMD_DATA, 0x0044, 239 << 8 | 0},
+ {LCD_STEP_CMD_DATA, 0x0045, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0046, 319},
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel tft2n0369e = {
+ .desc = "TFT2N0369E-Landscape",
+ .init_seq = tft2n0369e_init,
+ .horz_reg = 0x4e,
+ .vert_reg = 0x4f,
+ .gram_reg = 0x22,
+ .xres = 320,
+ .yres = 240,
+ .stride = 320,
+ .id = 0x8989,
+};
+#endif
+
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400D
+static const struct ubicom32lcd_step cfaf240400d_init[] = {
+ {LCD_STEP_CMD_DATA, 0x0606, 0x0000}, // Pin Control (R606h) // Page 41 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0001}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0110, 0x0001}, // Power Control 6(R110h) // Page 30 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0100, 0x17B0}, // Power Control 1 (R100h) // Page 26 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0101, 0x0147}, // Power Control 2 (R101h) // Page 27 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0102, 0x019D}, // Power Control 3 (R102h) // Page 28 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0103, 0x3600}, // Power Control 4 (R103h) // Page 29 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0281, 0x0010}, // NVM read data 2 (R281h) // Page 34 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0102, 0x01BD}, // Power Control 3 (R102h) // Page 28 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+
+ //--------------- Power control 1~6 ---------------//
+ {LCD_STEP_CMD_DATA, 0x0100, 0x16B0}, // Power Control 1 (R100h) // Page 26 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0101, 0x0147}, // Power Control 2 (R101h) // Page 27 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0102, 0x01BD}, // Power Control 3 (R102h) // Page 28 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0103, 0x2d00}, // Power Control 4 (R103h) // Page 29 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0107, 0x0000}, // Power Control 5 (R107h) // Page 30 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0110, 0x0001}, // Power Control 6(R110h) // Page 30 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0280, 0x0000}, // NVM read data 1 (R280h) // Page 33 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0281, 0x0006}, // NVM read data 2 (R281h) // Page 34 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0282, 0x0000}, // NVM read data 3 (R282h) // Page 34 of SPFD5420A Datasheet
+
+ //------- Gamma 2.2 control (R300h to R30Fh) ------//
+ {LCD_STEP_CMD_DATA, 0x0300, 0x0101},
+ {LCD_STEP_CMD_DATA, 0x0301, 0x0b27},
+ {LCD_STEP_CMD_DATA, 0x0302, 0x132a},
+ {LCD_STEP_CMD_DATA, 0x0303, 0x2a13},
+ {LCD_STEP_CMD_DATA, 0x0304, 0x270b},
+ {LCD_STEP_CMD_DATA, 0x0305, 0x0101},
+ {LCD_STEP_CMD_DATA, 0x0306, 0x1205},
+ {LCD_STEP_CMD_DATA, 0x0307, 0x0512},
+ {LCD_STEP_CMD_DATA, 0x0308, 0x0005},
+ {LCD_STEP_CMD_DATA, 0x0309, 0x0003},
+ {LCD_STEP_CMD_DATA, 0x030A, 0x0f04},
+ {LCD_STEP_CMD_DATA, 0x030B, 0x0f00},
+ {LCD_STEP_CMD_DATA, 0x030C, 0x000f},
+ {LCD_STEP_CMD_DATA, 0x030D, 0x040f},
+ {LCD_STEP_CMD_DATA, 0x030E, 0x0300},
+ {LCD_STEP_CMD_DATA, 0x030F, 0x0500},
+
+ {LCD_STEP_CMD_DATA, 0x0400, 0x3500}, // Base Image Number of Line (R400h) // Page 36 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0401, 0x0001}, // Base Image Display Control (R401h) // Page 39 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0404, 0x0000}, // Based Image Vertical Scroll Control (R404h) // Page 40 of SPFD5420A Datasheet
+
+ //--------------- Normal set ---------------//
+ {LCD_STEP_CMD_DATA, 0x0000, 0x0000}, // ID Read Register (R000h) // Page 13 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0001, 0x0100}, // Driver Output Control Register (R001h) // Page 14 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0100}, // LCD Driving Waveform Control (R002h) // Page 14 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0003, 0x1030}, // Entry Mode (R003h) // Page 15 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0006, 0x0000}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0008, 0x0808}, // Display Control 2 (R008h) // Page 17 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0009, 0x0001}, // Display Control 3 (R009h) // Page 18 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x000B, 0x0010}, // Low Power Control (R00Bh) // Page 19 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0000}, // External Display Interface Control 1 (R00Ch) // Page 19 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x000F, 0x0000}, // External Display Interface Control 2 (R00Fh) // Page 20 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0001}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+
+ //--------------- Panel interface control 1~6 ---------------//
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0012}, // Panel Interface Control 1 (R010h) // Page 20 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x0202}, // Panel Interface Control 2 (R011h) // Page 21 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x0300}, // Panel Interface control 3 (R012h) // Page 22 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0020, 0x021E}, // Panel Interface control 4 (R020h) // Page 22 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0021, 0x0202}, // Panel Interface Control 5 (021Rh) // Page 24 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0022, 0x0100}, // Panel Interface Control 6 (R022h) // Page 25 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0090, 0x8000}, // Frame Marker Control (R090h) // Page 25 of SPFD5420A Datasheet
+
+ //--------------- Partial display ---------------//
+ {LCD_STEP_CMD_DATA, 0x0210, 0x0000}, // Window Horizontal RAM Address Start (R210h) // Page 35 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0211, 0x00EF}, // Window Horziontal RAM Address End (R211h) // Page 35 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0212, 0x0000}, // Window Vertical RAM Address Start (R212h) // Page 35 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0213, 0x018F}, // Window Vertical RAM Address End (R213h) // Page 35 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0500, 0x0000}, // Display Position - Partial Display 1 (R500h) // Page 40 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0501, 0x0000}, // RAM Address Start - Partial Display 1 (R501h)// Page 40 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0502, 0x0000}, // RAM Address End - Partail Display 1 (R502h) // Page 40 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0503, 0x0000}, // Display Position - Partial Display 2 (R503h) // Page 40 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0504, 0x0000}, // RAM Address Start . Partial Display 2 (R504h)// Page 41 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0505, 0x0000}, // RAM Address End . Partial Display 2 (R505h) // Page 41 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0606, 0x0000}, // Pin Control (R606h) // Page 41 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x06F0, 0x0000}, // NVM Access Control (R6F0h) // Page 41 of SPFD5420A Datasheet
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0173}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 50},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0171}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+ {LCD_STEP_SLEEP, 0, 10},
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0173}, // Display Control 1 (R007h) // Page 16 of SPFD5420A Datasheet
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel cfaf240400d = {
+ .desc = "CFAF240400D",
+ .init_seq = cfaf240400d_init,
+ .horz_reg = 0x0200,
+ .vert_reg = 0x0201,
+ .gram_reg = 0x0202,
+ .xres = 240,
+ .yres = 400,
+ .stride = 240,
+ .id = 0x5420,
+};
+#endif
+
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400F
+static const struct ubicom32lcd_step cfaf320240f_init[] = {
+ {LCD_STEP_CMD_DATA, 0x0028, 0x0006}, // VCOM OTP Page 55-56 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0000, 0x0001}, // start Oscillator Page 36 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0010, 0x0000}, // Sleep mode Page 49 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0001, 0x32EF}, // Driver Output Control Page 36-39 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0002, 0x0600}, // LCD Driving Waveform Control Page 40-42 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0003, 0x6A38}, // Power Control 1 Page 43-44 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0011, 0x6870}, // Entry Mode Page 50-52 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0X000F, 0x0000}, // Gate Scan Position Page 49 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0X000B, 0x5308}, // Frame Cycle Control Page 45 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x000C, 0x0003}, // Power Control 2 Page 47 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x000D, 0x000A}, // Power Control 3 Page 48 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x000E, 0x2E00}, // Power Control 4 Page 48 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x001E, 0x00BE}, // Power Control 5 Page 53 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0025, 0x8000}, // Frame Frequency Control Page 53 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0026, 0x7800}, // Analog setting Page 54 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x004E, 0x0000}, // Ram Address Set Page 58 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x004F, 0x0000}, // Ram Address Set Page 58 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0012, 0x08D9}, // Sleep mode Page 49 of SSD2119 datasheet
+
+ // Gamma Control (R30h to R3Bh) -- Page 56 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0030, 0x0000},
+ {LCD_STEP_CMD_DATA, 0x0031, 0x0104},
+ {LCD_STEP_CMD_DATA, 0x0032, 0x0100},
+ {LCD_STEP_CMD_DATA, 0x0033, 0x0305},
+ {LCD_STEP_CMD_DATA, 0x0034, 0x0505},
+ {LCD_STEP_CMD_DATA, 0x0035, 0x0305},
+ {LCD_STEP_CMD_DATA, 0x0036, 0x0707},
+ {LCD_STEP_CMD_DATA, 0x0037, 0x0300},
+ {LCD_STEP_CMD_DATA, 0x003A, 0x1200},
+ {LCD_STEP_CMD_DATA, 0x003B, 0x0800},
+
+ {LCD_STEP_CMD_DATA, 0x0007, 0x0033}, // Display Control Page 45 of SSD2119 datasheet
+
+ {LCD_STEP_CMD_DATA, 0x0044, 0xEF00}, // Vertical RAM address position Page 57 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0045, 0x0000}, // Horizontal RAM address position Page 57 of SSD2119 datasheet
+ {LCD_STEP_CMD_DATA, 0x0046, 0x013F}, // Horizontal RAM address position Page 57 of SSD2119 datasheet
+
+ {LCD_STEP_SLEEP, 0, 150},
+
+ {LCD_STEP_DONE, 0, 0},
+};
+
+const struct ubicom32lcd_panel cfaf320240f = {
+ .desc = "CFAF320240F",
+ .init_seq = cfaf320240f_init,
+ .horz_reg = 0x4e,
+ .vert_reg = 0x4f,
+ .gram_reg = 0x22,
+ .xres = 320,
+ .yres = 240,
+ .stride = 320,
+ .id = 0x9919,
+};
+#endif
+
+const struct ubicom32lcd_panel *ubicom32lcd_panels[] = {
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400KTTS_180
+ &cfaf240320ktts_180,
+#endif
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400KTTS
+ &cfaf240320ktts_0,
+#endif
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400D
+ &cfaf240400d,
+#endif
+#ifdef CONFIG_LCD_UBICOM32_TFT2N0369E_P
+ &tft2n0369ep,
+#endif
+#ifdef CONFIG_LCD_UBICOM32_TFT2N0369E_L
+ &tft2n0369e,
+#endif
+#ifdef CONFIG_LCD_UBICOM32_CFAF240400F
+ &cfaf320240f,
+#endif
+ NULL,
+};
+
+#endif
diff --git a/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcdpower.c b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcdpower.c
new file mode 100644
index 000000000..6aeed43bc
--- /dev/null
+++ b/target/linux/ubicom32/files/drivers/video/backlight/ubicom32lcdpower.c
@@ -0,0 +1,194 @@
+/*
+ * drivers/video/backlight/ubicom32lcdpowerpower.c
+ * LCD power driver for the Ubicom32 platform
+ *
+ * (C) Copyright 2009, Ubicom, Inc.
+ *
+ * This file is part of the Ubicom32 Linux Kernel Port.
+ *
+ * The Ubicom32 Linux Kernel Port is free software: you can redistribute
+ * it and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Ubicom32 Linux Kernel Port is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the Ubicom32 Linux Kernel Port. If not,
+ * see <http://www.gnu.org/licenses/>.
+ *
+ * Ubicom32 implementation derived from (with many thanks):
+ * arch/m68knommu
+ * arch/blackfin
+ * arch/parisc
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/lcd.h>
+#include <linux/fb.h>
+#include <linux/gpio.h>
+
+#include <asm/ubicom32lcdpower.h>
+#include <asm/ip5000.h>
+
+#define DRIVER_NAME "ubicom32lcdpower"
+
+struct ubicom32lcdpower_data {
+ /*
+ * Pointer to the platform data structure. Keep this around since we need values
+ * from it to set the backlight intensity.
+ */
+ const struct ubicom32lcdpower_platform_data *pdata;
+
+ /*
+ * LCD device, we have to save this for use when we remove ourselves.
+ */
+ struct lcd_device *lcddev;
+};
+
+/*
+ * ubicom32lcdpower_set_power
+ */
+static int ubicom32lcdpower_set_power(struct lcd_device *ld, int power)
+{
+ struct ubicom32lcdpower_data *ud = (struct ubicom32lcdpower_data *)lcd_get_data(ld);
+ if (power == FB_BLANK_UNBLANK) {
+ gpio_direction_output(ud->pdata->vgh_gpio, ud->pdata->vgh_polarity);
+ return 0;
+ }
+
+ gpio_direction_output(ud->pdata->vgh_gpio, !ud->pdata->vgh_polarity);
+ return 0;
+}
+
+/*
+ * ubicom32lcdpower_get_power
+ */
+static int ubicom32lcdpower_get_power(struct lcd_device *ld)
+{
+ struct ubicom32lcdpower_data *ud = (struct ubicom32lcdpower_data *)lcd_get_data(ld);
+ int vgh = gpio_get_value(ud->pdata->vgh_gpio);
+ if ((vgh && ud->pdata->vgh_polarity) || (!vgh && !ud->pdata->vgh_polarity)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static struct lcd_ops ubicom32lcdpower_ops = {
+ .get_power = ubicom32lcdpower_get_power,
+ .set_power = ubicom32lcdpower_set_power,
+};
+
+/*
+ * ubicom32lcdpower_probe
+ */
+static int ubicom32lcdpower_probe(struct platform_device *pdev)
+{
+ const struct ubicom32lcdpower_platform_data *pdata = pdev->dev.platform_data;
+ struct ubicom32lcdpower_data *ud;
+ struct lcd_device *lcddev;
+ int retval;
+
+ /*
+ * Check to see if we have any platform data, if we don't have a LCD to control
+ */
+ if (!pdata) {
+ return -ENODEV;
+ }
+
+ /*
+ * Allocate our private data
+ */
+ ud = kzalloc(sizeof(struct ubicom32lcdpower_data), GFP_KERNEL);
+ if (!ud) {
+ return -ENOMEM;
+ }
+
+ ud->pdata = pdata;
+
+ /*
+ * Request our GPIOs
+ */
+ retval = gpio_request(pdata->vgh_gpio, "vgh");
+ if (retval) {
+ dev_err(&pdev->dev, "Failed to allocate vgh GPIO\n");
+ goto fail_gpio;
+ }
+
+ /*
+ * Register our lcd device
+ */
+ lcddev = lcd_device_register(DRIVER_NAME, &pdev->dev, ud, &ubicom32lcdpower_ops);
+ if (IS_ERR(lcddev)) {
+ retval = PTR_ERR(lcddev);
+ goto fail;
+ }
+
+ ud->lcddev = lcddev;
+ platform_set_drvdata(pdev, ud);
+
+ ubicom32lcdpower_set_power(lcddev, FB_BLANK_UNBLANK);
+
+ printk(KERN_INFO DRIVER_NAME ": LCD driver started\n");
+
+ return 0;
+
+fail:
+ gpio_free(pdata->vgh_gpio);
+
+fail_gpio:
+ platform_set_drvdata(pdev, NULL);
+ kfree(ud);
+ return retval;
+}
+
+/*
+ * ubicom32lcdpower_remove
+ */
+static int __exit ubicom32lcdpower_remove(struct platform_device *pdev)
+{
+ struct ubicom32lcdpower_data *ud = platform_get_drvdata(pdev);
+
+ lcd_device_unregister(ud->lcddev);
+ platform_set_drvdata(pdev, NULL);
+ kfree(ud);
+
+ return 0;
+}
+
+static struct platform_driver ubicom32lcdpower_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+
+ .remove = __exit_p(ubicom32lcdpower_remove),
+};
+
+/*
+ * ubicom32lcdpower_init
+ */
+static int __init ubicom32lcdpower_init(void)
+{
+ return platform_driver_probe(&ubicom32lcdpower_driver, ubicom32lcdpower_probe);
+}
+module_init(ubicom32lcdpower_init);
+
+/*
+ * ubicom32lcdpower_exit
+ */
+static void __exit ubicom32lcdpower_exit(void)
+{
+ platform_driver_unregister(&ubicom32lcdpower_driver);
+}
+module_exit(ubicom32lcdpower_exit);
+
+MODULE_AUTHOR("Patrick Tjin <@ubicom.com>");
+MODULE_DESCRIPTION("Ubicom32 lcd power driver");
+MODULE_LICENSE("GPL");