]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
H4 stops using gpio_expander_omap
authorDavid Brownell <dbrownell@users.sourceforge.net>
Wed, 29 Oct 2008 21:43:52 +0000 (14:43 -0700)
committerTony Lindgren <tony@atomide.com>
Thu, 13 Nov 2008 21:10:18 +0000 (13:10 -0800)
This patch starts updating the H4 board support to use gpiolib.  It
switches from the gpio_expander_omap.c code to the mainline pcf8474
driver for its three I2C GPIO expanders.

It also adds two minor features:  LCD stays powered off when it's not
used; and the backlight control is exposed through the LED framework
(using the new "backlight" trigger).

Plus it fixes a bug that would have affected anyone trying to use the
camera sensor:  it wouldn't power up, since 0x80 != 0x08.  (Though
there's no mainline V4L2 driver for that sensor yet...)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/Kconfig
arch/arm/mach-omap2/board-h4.c
arch/arm/plat-omap/include/mach/board-h4.h
drivers/i2c/chips/Kconfig
drivers/net/irda/Kconfig

index 27750f5112fd62d2e82f1bbe761cd0c8095a46bd..ca24a7a37c3c2725b40511568592dc79ccb8f98f 100644 (file)
@@ -62,7 +62,6 @@ config MACH_OMAP_H4
        bool "OMAP 2420 H4 board"
        depends on ARCH_OMAP2 && ARCH_OMAP2420
        select OMAP_DEBUG_DEVICES
-       select GPIOEXPANDER_OMAP
 
 config MACH_OMAP_H4_TUSB
        bool "TUSB 6010 EVM board"
index 62075b6491e0ac265f251c983970902856f0d845..e27da811603405cefeb2f73dfbc1c3caf5ab3961 100644 (file)
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/leds.h>
+
 #include <linux/i2c/at24.h>
 #include <linux/i2c/menelaus.h>
+#include <linux/i2c/pcf857x.h>
+
 #include <linux/spi/spi.h>
 #include <linux/spi/tsc210x.h>
 
@@ -37,8 +42,6 @@
 #include <asm/mach/flash.h>
 
 #include <mach/control.h>
-#include <mach/gpio.h>
-#include <mach/gpioexpander.h>
 #include <mach/mux.h>
 #include <mach/usb.h>
 #include <mach/irda.h>
@@ -140,32 +143,16 @@ static struct platform_device h4_flash_device = {
        .resource       = &h4_flash_resource,
 };
 
-/* Select between the IrDA and aGPS module
- */
 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
+
+/* Select between the IrDA and aGPS module */
 static int h4_select_irda(struct device *dev, int state)
 {
-       unsigned char expa;
-       int err = 0;
+       /* U192.P0 = high for IRDA; else AGPS */
+       gpio_set_value_cansleep(H4_GPIO_IRDA_AGPSn, state & IR_SEL);
 
-       if ((err = read_gpio_expa(&expa, 0x21))) {
-               printk(KERN_ERR "Error reading from I/O expander\n");
-               return err;
-       }
-
-       /* 'P6' enable/disable IRDA_TX and IRDA_RX */
-       if (state & IR_SEL) {   /* IrDa */
-               if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
-                       printk(KERN_ERR "Error writing to I/O expander\n");
-                       return err;
-               }
-       } else {
-               if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
-                       printk(KERN_ERR "Error writing to I/O expander\n");
-                       return err;
-               }
-       }
-       return err;
+       /* NOTE:  UART3 can also hook up to a DB9 or to GSM ... */
+       return 0;
 }
 
 static void set_trans_mode(struct work_struct *work)
@@ -173,22 +160,9 @@ static void set_trans_mode(struct work_struct *work)
        struct omap_irda_config *irda_config =
                container_of(work, struct omap_irda_config, gpio_expa.work);
        int mode = irda_config->mode;
-       unsigned char expa;
-       int err = 0;
 
-       if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
-               printk(KERN_ERR "Error reading from I/O expander\n");
-       }
-
-       expa &= ~0x01;
-
-       if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
-               expa |= 0x01;
-       }
-
-       if ((err = write_gpio_expa(expa, 0x20)) != 0) {
-               printk(KERN_ERR "Error writing to I/O expander\n");
-       }
+       /* U191.P0 = low for SIR; else MIR/FIR */
+       gpio_set_value_cansleep(H4_GPIO_IRDA_FIRSEL, !(mode & IR_SIRMODE));
 }
 
 static int h4_transceiver_mode(struct device *dev, int mode)
@@ -566,37 +540,13 @@ const static struct ov9640_reg ov9640_common[] = {
 
 static int ov9640_sensor_power_set(int power)
 {
-       unsigned char expa;
-       int err;
-
-       /* read current state of GPIO EXPA outputs */
-       if ((err = read_gpio_expa(&expa, 0x20))) {
-               printk(KERN_ERR "Error reading GPIO EXPA 0x20\n");
-               return err;
-       }
+       /* power up the sensor? */
+       gpio_set_value_cansleep(H4_GPIO_CAM_MODULE_EN, power);
 
-       expa = power ? expa | 0x80 : expa & ~0x08;
+       /* take it out of reset if it's not powered */
+       gpio_direction_output(H4_GPIO_CAM_RST, !power);
 
-       /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */
-       if ((err = write_gpio_expa(expa, 0x20))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA 0x20\n");
-               return err;
-       }
-
-       if (power) {
-               /* read current state of GPIO EXPA outputs */
-               if ((err = read_gpio_expa(&expa, 0x22))) {
-                       printk(KERN_ERR "Error reading GPIO EXPA\n");
-                       return err;
-               }
-               /* Clear GPIO EXPA P7 (CAM_RST) */
-               if ((err = write_gpio_expa(expa & ~0x80, 0x22))) {
-                       printk(KERN_ERR "Error writing to GPIO EXPA\n");
-                       return err;
-               }
-       }
-
-       return err;
+       return 0;
 }
 
 static struct v4l2_ifparm ifparm = {
@@ -624,14 +574,117 @@ static struct ov9640_platform_data h4_ov9640_platform_data = {
        .default_regs   = ov9640_common,
        .ifparm         = ov9640_ifparm,
 };
+
+#endif
+
+/* leave LCD powered off unless it will be used */
+#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
+#define LCD_ENABLED            true
+#else
+#define LCD_ENABLED            false
 #endif
 
+static struct gpio_led backlight_leds[] = {
+       {
+               .name                   = "lcd_h4",
+               .default_trigger        = "backlight",
+               .gpio                   = H4_GPIO_LCD_ENBKL,
+       },
+       { },
+};
+
+static struct gpio_led_platform_data backlight_led_data = {
+       .num_leds               = 1,
+       .leds                   = backlight_leds,
+};
+
+static struct platform_device h4_backlight_device = {
+       .name                   = "leds-gpio",
+       .id                     = 0,
+       .dev.platform_data      = &backlight_led_data,
+};
+
+static int
+u191_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *context)
+{
+       /* P0 = IRDA control, FIR/MIR vs SIR */
+       gpio_request(H4_GPIO_IRDA_FIRSEL, "irda_firsel");
+       gpio_direction_output(H4_GPIO_IRDA_FIRSEL, false);
+
+       /* P3 = camera sensor module PWDN */
+       gpio_request(H4_GPIO_CAM_MODULE_EN, "camera_en");
+       gpio_direction_output(H4_GPIO_CAM_MODULE_EN, false);
+
+       /* P7 = LCD_ENVDD ... controls power to LCD (including backlight)
+        * P5 = LCD_ENBKL ... switches backlight
+        */
+       gpio_request(H4_GPIO_LCD_ENVDD, "lcd_power");
+       gpio_direction_output(H4_GPIO_LCD_ENVDD, LCD_ENABLED);
+       if (LCD_ENABLED) {
+               h4_backlight_device.dev.parent = &client->dev;
+               platform_device_register(&h4_backlight_device);
+       }
+
+       /* P6 = AUDIO_ENVDD ... switch power to microphone */
+       gpio_request(H4_GPIO_AUDIO_ENVDD, "audio_power");
+       gpio_direction_output(H4_GPIO_AUDIO_ENVDD, true);
+
+       return 0;
+}
+
+
+static struct pcf857x_platform_data u191_platform_data = {
+       .gpio_base      = H4_U191_GPIO_BASE,
+       .setup          = u191_setup,
+};
+
+static int
+u192_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *context)
+{
+       gpio_request(H4_GPIO_IRDA_AGPSn, "irda/agps");
+       gpio_direction_output(H4_GPIO_IRDA_AGPSn, false);
+
+       return 0;
+}
+
+static struct pcf857x_platform_data u192_platform_data = {
+       .gpio_base      = H4_U192_GPIO_BASE,
+       .setup          = u192_setup,
+};
+
+static int
+u193_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *context)
+{
+       /* reset sensor */
+       gpio_request(H4_GPIO_CAM_RST, "camera_rst");
+       gpio_direction_output(H4_GPIO_CAM_RST, true);
+
+       return 0;
+}
+
+static struct pcf857x_platform_data u193_platform_data = {
+       .gpio_base      = H4_U193_GPIO_BASE,
+       .setup          = u193_setup,
+};
+
 static struct at24_platform_data m24c01 = {
        .byte_len       = SZ_1K / 8,
        .page_size      = 16,
 };
 
 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
+       {       /* U191 gpios */
+               I2C_BOARD_INFO("pcf8574", 0x20),
+               .platform_data  = &u191_platform_data,
+       },
+       {       /* U192 gpios */
+               I2C_BOARD_INFO("pcf8574", 0x21),
+               .platform_data  = &u192_platform_data,
+       },
+       {       /* U193 gpios */
+               I2C_BOARD_INFO("pcf8574", 0x22),
+               .platform_data  = &u193_platform_data,
+       },
        {
                I2C_BOARD_INFO("rv5c387a", 0x32),
                /* no IRQ wired to OMAP; nINTB goes to AGPS */
index 7c3fa0f0a65e1512b2efe9e55debfe199d87a789..60b3ce177a4c485f5c91796ec8d2b6cf0b541b04 100644 (file)
@@ -34,5 +34,47 @@ extern void h4_mmc_init(void);
 
 /* Placeholder for H4 specific defines */
 #define OMAP24XX_ETHR_GPIO_IRQ         92
+
+/* FPGA on debug board has 32 GPIOs:  16 dedicated to leds,
+ * 8 outputs on a header, and 6 inputs from a DIP switch.
+ */
+#define H4_DEBUG_GPIO_BASE             OMAP_MAX_GPIO_LINES
+#      define H4_DEBUG_GPIO_SW3_1      (H4_DEBUG_GPIO_BASE + 24)
+#      define H4_DEBUG_GPIO_SW3_2      (H4_DEBUG_GPIO_BASE + 25)
+#      define H4_DEBUG_GPIO_SW3_3      (H4_DEBUG_GPIO_BASE + 26)
+#      define H4_DEBUG_GPIO_SW3_4      (H4_DEBUG_GPIO_BASE + 27)
+#      define H4_DEBUG_GPIO_SW3_5      (H4_DEBUG_GPIO_BASE + 28)
+#      define H4_DEBUG_GPIO_SW3_8      (H4_DEBUG_GPIO_BASE + 29)
+
+/* H4 baseboard has 3 PCF8574 (8 bit) I2C GPIO expanders */
+#define H4_U191_GPIO_BASE              (H4_DEBUG_GPIO_BASE + 32)
+#      define H4_GPIO_IRDA_FIRSEL      (H4_U191_GPIO_BASE + 0)
+#      define H4_GPIO_MODEM_MOD_EN     (H4_U191_GPIO_BASE + 1)
+#      define H4_GPIO_WLAN_MOD_EN      (H4_U191_GPIO_BASE + 2)
+#      define H4_GPIO_CAM_MODULE_EN    (H4_U191_GPIO_BASE + 3)
+#      define H4_GPIO_HANDSET_EN       (H4_U191_GPIO_BASE + 4)
+#      define H4_GPIO_LCD_ENBKL        (H4_U191_GPIO_BASE + 5)
+#      define H4_GPIO_AUDIO_ENVDD      (H4_U191_GPIO_BASE + 6)
+#      define H4_GPIO_LCD_ENVDD        (H4_U191_GPIO_BASE + 7)
+
+#define H4_U192_GPIO_BASE              (H4_U191_GPIO_BASE + 8)
+#      define H4_GPIO_IRDA_AGPSn       (H4_U192_GPIO_BASE + 0)
+#      define H4_GPIO_AGPS_PWREN       (H4_U192_GPIO_BASE + 1)
+#      define H4_GPIO_AGPS_RSTn        (H4_U192_GPIO_BASE + 2)
+#      define H4_GPIO_AGPS_SLEEP       (H4_U192_GPIO_BASE + 3)
+#      define H4_GPIO_AGPS_PA_XMT      (H4_U192_GPIO_BASE + 4)
+#      define H4_GPIO_MODEM_SPR2       (H4_U192_GPIO_BASE + 5)
+#      define H4_GPIO_MODEM_SPR1       (H4_U192_GPIO_BASE + 6)
+#      define H4_GPIO_BT_ACLK_ENn      (H4_U192_GPIO_BASE + 7)
+
+#define H4_U193_GPIO_BASE              (H4_U192_GPIO_BASE + 8)
+#      define H4_GPIO_SPR0             (H4_U193_GPIO_BASE + 0)
+#      define H4_GPIO_SPR1             (H4_U193_GPIO_BASE + 1)
+#      define H4_GPIO_WLAN_SHUTDOWN    (H4_U193_GPIO_BASE + 2)
+#      define H4_GPIO_WLAN_RESET       (H4_U193_GPIO_BASE + 3)
+#      define H4_GPIO_WLAN_CLK_ENn     (H4_U193_GPIO_BASE + 4)
+       /* 5, 6 not connected */
+#      define H4_GPIO_CAM_RST          (H4_U193_GPIO_BASE + 7)
+
 #endif /*  __ASM_ARCH_OMAP_H4_H */
 
index 1bf3af2b3a2870f2343fa1532156ba5c49339a3b..4c73bb528e51d5f39c75fe8f88e78227cfdb5d19 100644 (file)
@@ -148,7 +148,7 @@ config SENSORS_TLV320AIC23
 
 config GPIOEXPANDER_OMAP
        bool "GPIO Expander PCF8574PWR for OMAP"
-       depends on I2C && (ARCH_OMAP16XX || ARCH_OMAP24XX)
+       depends on I2C && MACH_OMAP_H3
        help
          If you say yes here you get support for I/O expander calls
          to configure IrDA, Camera and audio devices.
index b83e25bde7b2b5abc7cca13b69808aadc62d0382..58d0c811afdfd2a1f87dd48da17e3e215596c0b1 100644 (file)
@@ -345,7 +345,7 @@ config MCS_FIR
 config OMAP_IR
        tristate "OMAP IrDA(SIR/MIR/FIR)"
        depends on IRDA && ARCH_OMAP
-       select GPIOEXPANDER_OMAP if (MACH_OMAP_H3 || MACH_OMAP_H4)
+       select GPIOEXPANDER_OMAP if MACH_OMAP_H3
         help
          Say Y here if you want to build support for the Texas Instruments
          OMAP IrDA device driver, which supports SIR/MIR/FIR. This driver