Message ID | 1371502684-17522-3-git-send-email-simon.guinot@sequanux.org |
---|---|
State | Superseded |
Delegated to: | Prafulla Wadaskar |
Headers | show |
> -----Original Message----- > From: Simon Guinot [mailto:simon.guinot@sequanux.org] > Sent: 18 June 2013 02:28 > To: Prafulla Wadaskar > Cc: Albert ARIBAUD; u-boot@lists.denx.de > Subject: [PATCH 2/3] LaCie/common: add support for the > GPIO extension bus > > This patch adds support for the GPIO extension bus > found on some LaCie > boards (as the 2Big/5Big Network v2 and the 2Big NAS). > This bus allows > to configure the devices (mostly the LEDs) connected to > a CPLD via two > GPIO-based registers (address and data). Hi Simon The name given here for the patch as well as files "gpio-ext" is confusing for me. As you stated here those are the IOs generated by CPLD on your board which can be programmed using bit-banging on two GPIOs. So to me it those are "cpld_ios". May you please rename these files accordingly and resend the patch series for better understanding? To me "gpio-ext" is generic term application for "General purpose IOs" Regards... Prafulla . . .
On Mon, Jun 17, 2013 at 11:53:53PM -0700, Prafulla Wadaskar wrote: > > > > -----Original Message----- > > From: Simon Guinot [mailto:simon.guinot@sequanux.org] > > Sent: 18 June 2013 02:28 > > To: Prafulla Wadaskar > > Cc: Albert ARIBAUD; u-boot@lists.denx.de > > Subject: [PATCH 2/3] LaCie/common: add support for the > > GPIO extension bus > > > > This patch adds support for the GPIO extension bus > > found on some LaCie > > boards (as the 2Big/5Big Network v2 and the 2Big NAS). > > This bus allows > > to configure the devices (mostly the LEDs) connected to > > a CPLD via two > > GPIO-based registers (address and data). > > Hi Simon Hi Prafulla, Thanks for your quick answer. > The name given here for the patch as well as files "gpio-ext" is confusing for me. > > As you stated here those are the IOs generated by CPLD on your board which can be programmed using bit-banging on two GPIOs. Not really bit-banging. Here we have 3 GPIOs used as a kind of address register and 3 other GPIOs used as a kind of data register. An another GPIO is used to notify the CPLD than the registers have been updated. I will update the patch description to make clear that a register may include several GPIOs. At LaCie, this kind of bus is called a "GPIO extension bus". It is like a cheap GPIO expander. > > So to me it those are "cpld_ios". I am not sure that behind this kind of bus we always have a CPLD. I will check this. If it is the case, what do you think about cpld-gpio-bus ? Moreover as this "bus" is really a lacie specific stuff, should I prepend a "lacie-" prefix ? Regards, Simon > > May you please rename these files accordingly and resend the patch series for better understanding? > > To me "gpio-ext" is generic term application for "General purpose IOs" > > Regards... > Prafulla . . .
> -----Original Message----- > From: Simon Guinot [mailto:simon.guinot@sequanux.org] > Sent: 18 June 2013 15:59 > To: Prafulla Wadaskar > Cc: Albert ARIBAUD; u-boot@lists.denx.de > Subject: Re: [PATCH 2/3] LaCie/common: add support for > the GPIO extension bus > > On Mon, Jun 17, 2013 at 11:53:53PM -0700, Prafulla > Wadaskar wrote: > > > > > > > -----Original Message----- > > > From: Simon Guinot > [mailto:simon.guinot@sequanux.org] > > > Sent: 18 June 2013 02:28 > > > To: Prafulla Wadaskar > > > Cc: Albert ARIBAUD; u-boot@lists.denx.de > > > Subject: [PATCH 2/3] LaCie/common: add support for > the > > > GPIO extension bus ...snip... > At LaCie, this kind of bus is called a "GPIO extension > bus". It is like > a cheap GPIO expander. > > > > > So to me it those are "cpld_ios". > > I am not sure that behind this kind of bus we always > have a CPLD. I will > check this. If it is the case, what do you think about > cpld-gpio-bus ? Even this sounds good to me, better than my suggestion earlier :). > > Moreover as this "bus" is really a lacie specific stuff, > should I > prepend a "lacie-" prefix ? This is not necessary I think. Regards... Prafulla . . .
diff --git a/board/LaCie/common/gpio-ext.c b/board/LaCie/common/gpio-ext.c new file mode 100644 index 0000000..1e1b7ff --- /dev/null +++ b/board/LaCie/common/gpio-ext.c @@ -0,0 +1,47 @@ +/* + * gpio-ext.c: provides support for the GPIO extension bus found on some + * LaCie boards (as the 2Big/5Big Network v2 and the 2Big NAS). This bus + * allows to configure the devices (mostly the LEDs) connected to a CPLD + * via two GPIO-based registers (address and data). + * + * Copyright (C) 2013 Simon Guinot <simon.guinot@sequanux.org> + * + * 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. + */ + +#include <asm/arch/gpio.h> +#include "gpio-ext.h" + +static void gpio_ext_set_addr(struct gpio_ext *gpio_ext, unsigned addr) +{ + int pin; + + for (pin = 0; pin < gpio_ext->num_addr; pin++) + kw_gpio_set_value(gpio_ext->addr[pin], (addr >> pin) & 1); +} + +static void gpio_ext_set_data(struct gpio_ext *gpio_ext, unsigned data) +{ + int pin; + + for (pin = 0; pin < gpio_ext->num_data; pin++) + kw_gpio_set_value(gpio_ext->data[pin], (data >> pin) & 1); +} + +static void gpio_ext_enable_select(struct gpio_ext *gpio_ext) +{ + /* The transfer is enabled on the raising edge. */ + kw_gpio_set_value(gpio_ext->enable, 0); + kw_gpio_set_value(gpio_ext->enable, 1); +} + +void gpio_ext_set_value(struct gpio_ext *gpio_ext, + unsigned addr, unsigned value) +{ + gpio_ext_set_addr(gpio_ext, addr); + gpio_ext_set_data(gpio_ext, value); + gpio_ext_enable_select(gpio_ext); +} diff --git a/board/LaCie/common/gpio-ext.h b/board/LaCie/common/gpio-ext.h new file mode 100644 index 0000000..09fa271 --- /dev/null +++ b/board/LaCie/common/gpio-ext.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2013 Simon Guinot <simon.guinot@sequanux.org> + * + * 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. + */ + +#ifndef _LACIE_GPIO_EXT_H +#define _LACIE_GPIO_EXT_H + +struct gpio_ext { + unsigned *addr; + unsigned num_addr; + unsigned *data; + unsigned num_data; + unsigned enable; +}; + +void gpio_ext_set_value(struct gpio_ext *gpio_ext, + unsigned addr, unsigned value); + +#endif /* _LACIE_GPIO_EXT_H */
This patch adds support for the GPIO extension bus found on some LaCie boards (as the 2Big/5Big Network v2 and the 2Big NAS). This bus allows to configure the devices (mostly the LEDs) connected to a CPLD via two GPIO-based registers (address and data). Signed-off-by: Simon Guinot <simon.guinot@sequanux.org> --- board/LaCie/common/gpio-ext.c | 47 +++++++++++++++++++++++++++++++++++++++++ board/LaCie/common/gpio-ext.h | 24 +++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 board/LaCie/common/gpio-ext.c create mode 100644 board/LaCie/common/gpio-ext.h