David Brownell <[EMAIL PROTECTED]> writes:

> On Thursday 28 August 2008, Kevin Hilman wrote:
>> From: David Brownell <[EMAIL PROTECTED]>
>> 
>> Remove the two (!) legacy GPIO expander modules for DaVinci U35,
>> and provide standard GPIO framework support for that chip ... but
>> without any particular intelligence.
>
> Hmm, I thought you were going to use the updated version
> (appended) with improved intelligence ... merging your
> updates (resolving the IDE-doesn't-work issue too) and
> mine (freeing other gpios just-in-case, etc).
>

Yes, I thought I had merged those together.  Thanks for the check.
I'll update in my staging tree before pushing.

Kevin

>
>
> ======================================
> From: David Brownell <[EMAIL PROTECTED]>
>
> Remove the two (!) legacy GPIO expander modules for DaVinci U35,
> and provide standard GPIO framework support for that chip.  It's
> initialized so that IDE drives work.  The EVM support in the musb
> driver now uses GPIO calls to access that signal.
>
> This breaks the build for the RTC driver.  Probably all the msp430
> related code should get updated to use the MFD framework.
>
> Signed-off-by: David Brownell <[EMAIL PROTECTED]>
> ---
>  arch/arm/mach-davinci/Kconfig                   |    9 -
>  arch/arm/mach-davinci/Makefile                  |    1 
>  arch/arm/mach-davinci/board-evm.c               |   72 +++++++--
>  arch/arm/mach-davinci/i2c-client.c              |  166 ----------------------
>  arch/arm/mach-davinci/include/mach/i2c-client.h |   34 ----
>  drivers/i2c/chips/Kconfig                       |    6 
>  drivers/i2c/chips/Makefile                      |    1 
>  drivers/i2c/chips/gpio_expander_davinci.c       |  143 ------------------
>  drivers/usb/musb/davinci.c                      |    8 -
>  9 files changed, 61 insertions(+), 379 deletions(-)
>
> --- a/arch/arm/mach-davinci/Kconfig
> +++ b/arch/arm/mach-davinci/Kconfig
> @@ -14,19 +14,10 @@ config MACH_DAVINCI_EVM
>       bool "TI DaVinci EVM"
>       default y
>       depends on ARCH_DAVINCI644x
> -     select GPIOEXPANDER_DAVINCI
>       help
>         Configure this option to specify the whether the board used
>         for development is a DaVinci EVM
>  
> -config DAVINCI_I2C_EXPANDER
> -     bool "TI DaVinci I2C Expander"
> -     default y
> -     depends on I2C && ARCH_DAVINCI644x
> -     help
> -       Configure this option to specify whether the board used
> -       has I2C exapnder with ATA, USB, CF.
> -
>  config DAVINCI_MCBSP
>       bool
>          prompt "DaVinci McBSP Driver" if SOUND_DAVINCI=n
> --- a/arch/arm/mach-davinci/Makefile
> +++ b/arch/arm/mach-davinci/Makefile
> @@ -10,4 +10,3 @@ obj-y                       := time.o irq.o clock.o serial.
>  # Board specific
>  obj-$(CONFIG_MACH_DAVINCI_EVM)       += board-evm.o
>  obj-$(CONFIG_DAVINCI_MCBSP)          += mcbsp.o
> -obj-$(CONFIG_DAVINCI_I2C_EXPANDER)   += i2c-client.o
> --- a/arch/arm/mach-davinci/board-evm.c
> +++ b/arch/arm/mach-davinci/board-evm.c
> @@ -327,11 +327,62 @@ static struct pcf857x_platform_data pcf_
>  
>  /* U35 - various I/O signals used to manage USB, CF, ATA, etc */
>  
> -#if 0
> +static int
> +evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
> +{
> +     /* REVISIT -- get polarity of these right; active low == 'n' prefix */
> +
> +     /* p0 = nDRV_VBUS (initial:  don't supply it) */
> +     gpio_request(gpio + 0, "nDRV_VBUS");
> +     gpio_direction_output(gpio + 0, 1);
> +
> +     /* p1 = VDDIMX_EN */
> +     gpio_request(gpio + 1, "VDDIMX_EN");
> +     gpio_direction_output(gpio + 1, 1);
> +
> +     /* p2 = VLYNQ_EN */
> +     gpio_request(gpio + 2, "VLYNQ_EN");
> +     gpio_direction_output(gpio + 2, 1);
> +
> +     /* p3 = n3V3_CF_RESET (initial: stay in reset) */
> +     gpio_request(gpio + 3, "nCF_RESET");
> +     gpio_direction_output(gpio + 3, 0);
> +
> +     /* (p4 unused) */
> +
> +     /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
> +     gpio_request(gpio + 5, "WLAN_RESET");
> +     gpio_direction_output(gpio + 5, 1);
> +
> +     /* p6 = nATA_SEL (initial: select) */
> +     gpio_request(gpio + 6, "nATA_SEL");
> +     gpio_direction_output(gpio + 6, 0);
> +
> +     /* p7 = nCF_SEL (initial: deselect) */
> +     gpio_request(gpio + 7, "nCF_SEL");
> +     gpio_direction_output(gpio + 7, 1);
> +
> +     return 0;
> +}
> +
> +static int
> +evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void 
> *c)
> +{
> +     gpio_free(gpio + 7);
> +     gpio_free(gpio + 6);
> +     gpio_free(gpio + 5);
> +     gpio_free(gpio + 3);
> +     gpio_free(gpio + 2);
> +     gpio_free(gpio + 1);
> +     gpio_free(gpio + 0);
> +     return 0;
> +}
> +
>  static struct pcf857x_platform_data pcf_data_u35 = {
> -     .gpio_base = PCF_Uxx_BASE(2),
> +     .gpio_base      = PCF_Uxx_BASE(2),
> +     .setup          = evm_u35_setup,
> +     .teardown       = evm_u35_teardown,
>  };
> -#endif
>  
>  /*----------------------------------------------------------------------*/
>  
> @@ -385,26 +436,17 @@ EXPORT_SYMBOL(dm6446evm_eeprom_write);
>  
>  static struct i2c_board_info __initdata i2c_info[] =  {
>       {
> -             I2C_BOARD_INFO("pcf857x", 0x38),
> -             .type           = "pcf8574",
> +             I2C_BOARD_INFO("pcf8574", 0x38),
>               .platform_data  = &pcf_data_u2,
>       },
>       {
> -             I2C_BOARD_INFO("pcf857x", 0x39),
> -             .type           = "pcf8574",
> +             I2C_BOARD_INFO("pcf8574", 0x39),
>               .platform_data  = &pcf_data_u18,
>       },
> -#if 0
> -/* don't clash with mach-davinci/i2c-client.c
> - * or drivers/i2c/chips/gpio_expander_davinci.c
> - * ... eventually both should vanish
> - */
>       {
> -             I2C_BOARD_INFO("pcf857x", 0x3a),
> -             .type           = "pcf8574a",
> +             I2C_BOARD_INFO("pcf8574", 0x3a),
>               .platform_data  = &pcf_data_u35,
>       },
> -#endif
>       {
>               I2C_BOARD_INFO("24c256", 0x50),
>               .platform_data  = &eeprom_info,
> --- a/arch/arm/mach-davinci/i2c-client.c
> +++ /dev/null
> @@ -1,166 +0,0 @@
> -/*
> - *  linux/drivers/davinci/i2c-davinci-client.c
> - *
> - * Copyright (C) 2006 Texas Instruments Inc
> - *
> - * This program 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 program 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 this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> - */
> -
> -#include <linux/init.h>
> -#include <linux/fs.h>
> -#include <linux/vmalloc.h>
> -#include <linux/slab.h>
> -#include <linux/proc_fs.h>
> -#include <linux/ctype.h>
> -#include <linux/delay.h>
> -#include <linux/i2c.h>
> -#include <linux/clk.h>
> -#include <linux/semaphore.h>
> -
> -#include <mach/i2c-client.h>
> -
> -static DEFINE_MUTEX(expander_lock);
> -static struct i2c_client *client_handle;
> -
> -/* This function is used for internal initialization */
> -int davinci_i2c_read(u8 size, u8 * val, u16 client_addr)
> -{
> -     int err;
> -     struct i2c_client *client = client_handle;
> -
> -     struct i2c_msg msg[1];
> -
> -     if (!client->adapter)
> -             return -ENODEV;
> -
> -     msg->addr = client_addr;
> -     msg->flags = I2C_M_RD;
> -     msg->len = size;
> -     msg->buf = val;
> -
> -     err = i2c_transfer(client->adapter, msg, 1);
> -
> -     if (err >= 0) {
> -             return 0;
> -     }
> -
> -     return err;
> -}
> -
> -EXPORT_SYMBOL(davinci_i2c_read);
> -
> -/* This function is used for internal initialization */
> -int davinci_i2c_write(u8 size, u8 * val, u16 client_addr)
> -{
> -     int err;
> -     struct i2c_client *client = client_handle;
> -
> -     struct i2c_msg msg[1];
> -
> -     if (!client->adapter)
> -             return -ENODEV;
> -
> -     msg->addr = client_addr;
> -     msg->flags = 0;
> -     msg->len = size;
> -     msg->buf = val;
> -
> -     err = i2c_transfer(client->adapter, msg, 1);
> -     if (err >= 0)
> -             return 0;
> -
> -     return err;
> -}
> -
> -EXPORT_SYMBOL(davinci_i2c_write);
> -
> -static struct i2c_driver davinci_i2c_client_driver;
> -
> -static int davinci_i2c_attach_client(struct i2c_adapter *adap, int addr)
> -{
> -     struct i2c_client *client;
> -     int err;
> -     u8 data_to_u35 = 0xf6;
> -
> -     if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
> -             err = -ENOMEM;
> -             goto exit;
> -     }
> -     client_handle = client;
> -
> -     if (client->adapter)
> -             return -EBUSY;  /* our client is already attached */
> -
> -     client->addr = addr;
> -     client->flags = 0;
> -     client->driver = &davinci_i2c_client_driver;
> -     client->adapter = adap;
> -     strlcpy(client->name, client->driver->driver.name, I2C_NAME_SIZE);
> -
> -     err = i2c_attach_client(client);
> -     if (err) {
> -             client->adapter = NULL;
> -             goto exit_kfree;
> -     }
> -
> -     err = davinci_i2c_write(1, &data_to_u35, 0x3A);
> -
> -     return 0;
> -
> - exit_kfree:
> -     kfree(client);
> - exit:
> -     return err;
> -}
> -
> -static int davinci_i2c_detach_client(struct i2c_client *client)
> -{
> -     int err;
> -
> -     if (!client->adapter)
> -             return -ENODEV; /* our client isn't attached */
> -
> -     err = i2c_detach_client(client);
> -     client->adapter = NULL;
> -     return err;
> -}
> -
> -static int davinci_i2c_probe_adapter(struct i2c_adapter *adap)
> -{
> -     return davinci_i2c_attach_client(adap, 0x3A);
> -}
> -
> -/* This is the driver that will be inserted */
> -static struct i2c_driver davinci_i2c_client_driver = {
> -     .driver = {
> -             /* there are 3 expanders, one is leds-only ... */
> -             .name   = "davinci_evm_expander1",
> -     },
> -     .attach_adapter = davinci_i2c_probe_adapter,
> -     .detach_client  = davinci_i2c_detach_client,
> -};
> -
> -static int __init davinci_i2c_client_init(void)
> -{
> -     return i2c_add_driver(&davinci_i2c_client_driver);
> -}
> -
> -static void __exit davinci_i2c_client_exit(void)
> -{
> -     i2c_del_driver(&davinci_i2c_client_driver);
> -}
> -
> -module_init(davinci_i2c_client_init);
> -module_exit(davinci_i2c_client_exit);
> --- a/arch/arm/mach-davinci/include/mach/i2c-client.h
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - *  include/asm-arm/arch-davinci/i2c-client.h
> - *
> - * Copyright (C) 2006 Texas Instruments Inc
> - *
> - * This program 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 program 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 this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> - */
> -/* i2c-client.h */
> -
> -typedef enum {
> -        USB_DRVVBUS = 0,
> -        VDDIMX_EN = 1,
> -        VLYNQ_ON = 2,
> -        CF_RESET = 3,
> -        WLAN_RESET = 4,
> -        ATA_SEL = 5,
> -        CF_SEL = 6
> -} u35_expander_ops;
> -
> -int davinci_i2c_expander_op (u16 client_addr, u35_expander_ops pin, u8 val);
> -int davinci_i2c_write(u8 size, u8 * val, u16 client_addr);
> -int davinci_i2c_read(u8 size, u8 * val, u16 client_addr);
> --- a/drivers/i2c/chips/Kconfig
> +++ b/drivers/i2c/chips/Kconfig
> @@ -267,10 +267,4 @@ config MENELAUS
>         and other features that are often used in portable devices like
>         cell phones and PDAs.
>  
> -config GPIOEXPANDER_DAVINCI
> -        bool "GPIO Expander for DaVinci"
> -        depends on I2C && ARCH_DAVINCI
> -        help
> -          If you say yes here you get support for I/O expander calls
> -
>  endmenu
> --- a/drivers/i2c/chips/Makefile
> +++ b/drivers/i2c/chips/Makefile
> @@ -31,7 +31,6 @@ obj-$(CONFIG_TWL4030_POWEROFF)      += twl403
>  obj-$(CONFIG_TWL4030_PWRBUTTON)      += twl4030-pwrbutton.o
>  obj-$(CONFIG_TWL4030_MADC)   += twl4030-madc.o
>  obj-$(CONFIG_RTC_X1205_I2C)  += x1205.o
> -obj-$(CONFIG_GPIOEXPANDER_DAVINCI) += gpio_expander_davinci.o
>  
>  ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
>  EXTRA_CFLAGS += -DDEBUG
> --- a/drivers/i2c/chips/gpio_expander_davinci.c
> +++ /dev/null
> @@ -1,143 +0,0 @@
> -/*
> - * drivers/i2c/chips/gpio_expander_davinci.c
> - *
> - * Author: Vladimir Barinov, MontaVista Software, Inc. <[EMAIL PROTECTED]>
> - *
> - * Copyright (C) 2006 Texas Instruments Inc
> - *
> - * 2007 (c) MontaVista Software, Inc. This file is licensed under
> - * the terms of the GNU General Public License version 2. This program
> - * is licensed "as is" without any warranty of any kind, whether express
> - * or implied.
> - */
> -
> -#include <linux/types.h>
> -#include <linux/i2c.h>
> -#include <linux/errno.h>
> -#include <linux/mutex.h>
> -
> -#include <mach/i2c-client.h>
> -
> -static DEFINE_MUTEX(expander_lock);
> -
> -static int davinci_i2c_expander_read(u8 size, u8 * val, u16 addr)
> -{
> -     struct i2c_adapter *adap;
> -     int err;
> -     struct i2c_msg msg[1];
> -
> -     adap = i2c_get_adapter(1);
> -     if (!adap)
> -             return -ENODEV;
> -
> -     msg->addr = addr;
> -     msg->flags = I2C_M_RD;
> -     msg->len = size;
> -     msg->buf = val;
> -
> -     err = i2c_transfer(adap, msg, 1);
> -     if (err >= 0)
> -             return 0;
> -
> -     return err;
> -}
> -
> -static int davinci_i2c_expander_write(u8 size, u8 * val, u16 addr)
> -{
> -     struct i2c_adapter *adap;
> -     int err;
> -     struct i2c_msg msg[1];
> -
> -     adap = i2c_get_adapter(1);
> -     if (!adap)
> -             return -ENODEV;
> -
> -     msg->addr = addr;
> -     msg->flags = 0;
> -     msg->len = size;
> -     msg->buf = val;
> -
> -     err = i2c_transfer(adap, msg, 1);
> -     if (err >= 0)
> -             return 0;
> -
> -     return err;
> -}
> -
> -int davinci_i2c_expander_op(u16 client_addr, u35_expander_ops pin, u8 val)
> -{
> -     int err = 0;
> -     char cmd[4] = { 4, 6, 0x00, 0x09 };
> -     u8 data_to_u35 = 0;
> -
> -     if (val > 1)
> -             return -1;
> -
> -     mutex_lock(&expander_lock);
> -
> -     err = davinci_i2c_expander_read(1, &data_to_u35, 0x3A);
> -     if (err < 0)
> -             goto out;
> -
> -     if (client_addr == 0x3A) {
> -             switch (pin) {
> -             case USB_DRVVBUS:
> -                     if (val)
> -                             data_to_u35 |= val;
> -                     else
> -                             data_to_u35 &= (val | 0xFE);
> -                     break;
> -             case VDDIMX_EN:
> -                     if (val)
> -                             data_to_u35 |= (val << 1);
> -                     else
> -                             data_to_u35 &= (val | 0xFD);
> -                     break;
> -             case VLYNQ_ON:
> -                     if (val)
> -                             data_to_u35 |= (val << 2);
> -                     else
> -                             data_to_u35 &= (val | 0xFB);
> -                     break;
> -             case CF_RESET:
> -                     if (val)
> -                             data_to_u35 |= (val << 3);
> -                     else
> -                             data_to_u35 &= (val | 0xF7);
> -                     break;
> -             case WLAN_RESET:
> -                     if (val)
> -                             data_to_u35 |= (val << 5);
> -                     else
> -                             data_to_u35 &= (val | 0xDF);
> -                     break;
> -             case ATA_SEL:
> -                     if (val)
> -                             data_to_u35 |= (val << 6);
> -                     else
> -                             data_to_u35 &= (val | 0xBF);
> -                     break;
> -             case CF_SEL:
> -                     davinci_i2c_expander_write(4, cmd, 0x23);
> -                     if (val)
> -                             data_to_u35 |= (val << 7);
> -                     else
> -                             data_to_u35 &= (val | 0x7F);
> -                     break;
> -             default:
> -                     break;
> -             }
> -     } else {
> -             printk("Only IO Expander at address 0x3A is supported\n");
> -             err = -EINVAL;
> -             goto out;
> -     }
> -
> -     err = davinci_i2c_expander_write(1, &data_to_u35, 0x3A);
> -
> -out:
> -     mutex_unlock(&expander_lock);
> -
> -     return err;
> -}
> -EXPORT_SYMBOL(davinci_i2c_expander_op);
> --- a/drivers/usb/musb/davinci.c
> +++ b/drivers/usb/musb/davinci.c
> @@ -30,16 +30,16 @@
>  #include <linux/delay.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> +#include <linux/gpio.h>
>  
>  #include <mach/hardware.h>
>  #include <mach/memory.h>
> -#include <mach/gpio.h>
>  #include <asm/mach-types.h>
>  
>  #include "musb_core.h"
>  
>  #ifdef CONFIG_MACH_DAVINCI_EVM
> -#include <mach/i2c-client.h>
> +#define GPIO_nVBUS_DRV               87
>  #endif
>  
>  #include "davinci.h"
> @@ -145,7 +145,7 @@ static int vbus_state = -1;
>   */
>  static void evm_deferred_drvvbus(struct work_struct *ignored)
>  {
> -     davinci_i2c_expander_op(0x3a, USB_DRVVBUS, vbus_state);
> +     gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
>       vbus_state = !vbus_state;
>  }
>  static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);
> @@ -164,7 +164,7 @@ static void davinci_source_power(struct 
>  #ifdef CONFIG_MACH_DAVINCI_EVM
>       if (machine_is_davinci_evm()) {
>               if (immediate)
> -                     davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on);
> +                     gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
>               else
>                       schedule_work(&evm_vbus_work);
>       }

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to