nios2: add gpio based status led driver
Subsystems (5)
PATCH 1/1 nios2: add gpio based status led driver
This patch adds a gpio based status led driver. The led mask is used to specify the gpio pin.
--- board/altera/common/gpioled.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) create mode 100644 board/altera/common/gpioled.c
board/altera/common/gpioled.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Status LED driver based on gpio +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <common.h> +#include <status_led.h> +#include <asm/gpio.h> + +/* assume led is active low */ + +void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
Signature · 1 line
1.6.6.1
PATCH 1/1 nios2: add gpio based status led driver
Thomas,
Quoted 24 lines · Thomas Chou
This patch adds a gpio based status led driver. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou <[email protected]>--- board/altera/common/gpioled.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) create mode 100644 board/altera/common/gpioled.cboard/altera/common/gpioled.c new file +9
-0@@ -0,0 +1,30 @@ +/* +* Status LED driver based on gpio +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/
board/altera/common/gpioled.c line 19
Quoted 10 lines
board/altera/common/gpioled.c new file +10
-0+ +#include <common.h> +#include <status_led.h> +#include <asm/gpio.h> + +/* assume led is active low */ + +void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 );
The direction register only exists when the PIO core hardware is configured in bidirectional mode.
board/altera/common/gpioled.c line 30
Quoted 9 lines
board/altera/common/gpioled.c new file +9
-0+void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
If the PIO core hardware is configured in output-only mode, reading from data returns an undefined value.
As I recall, the older designs configured the LED PIO ports as output only ... which is why board/altera/common/epled.c was coded in such a manner.
Regards,
--Scott
PATCH 1/1 nios2: add gpio based status led driver
Quoted 8 lines · Scott McNutt
board/altera/common/gpioled.c line 19
Quoted 3 lines
board/altera/common/gpioled.c new file +3
-0+void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 );The direction register only exists when the PIO core hardware is configured in bidirectional mode.
Quoted 7 lines
If the PIO core hardware is configured in output-only mode, reading from data returns an undefined value.
As I recall, the older designs configured the LED PIO ports as output only ... which is why
board/altera/common/epled.cwas coded in such a manner.
Hi Scott,
This is not for Altera PIO interface. I followed the gpio interface of Linux, linux-2.6/Documentation/gpio.txt, and created a trivial bit addressing gpio core, which uses fewer LE and doesn't required interrupt disabled to write a bit. With this core, all output pins are bidirectional and can be read. I used it to access i2c, one-wire, leds, buttons and nand flash busy flag in nios2 linux. I didn't add irq support, because input layer of linux can do debounce. Please look at
http://nioswiki.com/GPIO.
Best regards,
Thomas
PATCH 1/1 nios2: add gpio based status led driver
Quoted 16 lines · Thomas Chou
Quoted 8 lines · Scott McNutt
board/altera/common/gpioled.c line 19
Quoted 3 lines
board/altera/common/gpioled.c new file +3
-0+void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 );The direction register only exists when the PIO core hardware is configured in bidirectional mode.
Quoted 7 lines
If the PIO core hardware is configured in output-only mode, reading from data returns an undefined value.
As I recall, the older designs configured the LED PIO ports as output only ... which is why
board/altera/common/epled.cwas coded in such a manner.
Quoted 5 lines
Hi Scott,
This is not for Altera PIO interface. I followed the gpio interface of Linux,
linux-2.6/Documentation/gpio.txt, and created a trivial bit addressing gpio core,
I don't think the Altera board tree is an appropriate place for code that supports custom logic blocks. If an Altera distribution provided a design that included this custom block in one of their board designs then it would probably be fine.
I'm not sure where this should go ... maybe in the driver tree?
Regards,
--Scott
PATCH 1/1 nios2: add gpio based status led driver
Quoted 8 lines · Scott McNutt
I don't think the Altera board tree is an appropriate place for code that supports custom logic blocks. If an Altera distribution provided a design that included this custom block in one of their board designs then it would probably be fine.
I'm not sure where this should go ... maybe in the driver tree?
Hi Scott,
Thanks. I will move it to drivers/misc.
Cheers,
Thomas
PATCH v2 1/1 misc: add gpio based status led driver
In reply to Thomas ChouThis patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
---
Moved to drivers/misc.
drivers/misc/Makefile | 1 + drivers/misc/gpio_led.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/gpio_led.c
drivers/misc/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB := $(obj)libmisc.a COBJS-$(CONFIG_ALI152X) += ali512x.o COBJS-$(CONFIG_DS4510) += ds4510.o COBJS-$(CONFIG_FSL_LAW) += fsl_law.o +COBJS-$(CONFIG_GPIO_LED) += gpio_led.o COBJS-$(CONFIG_NS87308) += ns87308.o COBJS-$(CONFIG_STATUS_LED) += status_led.o COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.o
drivers/misc/gpio_led.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Status LED driver based on GPIO access conventions of Linux +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <common.h> +#include <status_led.h> +#include <asm/gpio.h> + +/* assume led is active low */ + +void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
Signature · 1 line
1.6.6.1
PATCH v2 1/1 misc: add gpio based status led driver
Dear Thomas Chou,
Quoted 6 lines · In message <[email protected]> you wrote:
This patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou <[email protected]>---
Moved todrivers/misc.
Which boards are the users of this code?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Conceptual integrity in turn dictates that the design must proceed from one mind, or from a very small number of agreeing resonant minds. - Frederick Brooks Jr., "The Mythical Man Month"
PATCH v2 1/1 misc: add gpio based status led driver
Quoted 11 lines · Wolfgang Denk
Dear Thomas Chou,
Quoted 7 lines · In message<[email protected]> you wrote:
This patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou<[email protected]>---
Moved todrivers/misc.
Quoted 7 lines
Which boards are the users of this code?
Best regards,
Wolfgang Denk
Hi Wolfgang,
It is used in the example designs of Altera NEEK and DE2 boards, which I provided for nios2 linux/uclinux on nios wiki. They are used by many nios2 users.
It may be used by other boards which support the GPIO access conventions of Linux. Though the GPIO access is not unified in u-boot currently, I think it should be the right direction to follow the conventions of Linux.
Best regards,
Thomas
PATCH v2 1/1 misc: add gpio based status led driver
Dear Thomas Chou,
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 9 lines
Quoted 8 lines
This patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou<[email protected]>---
Moved todrivers/misc.Which boards are the users of this code?
...
Quoted 7 lines
It is used in the example designs of Altera NEEK and DE2 boards, which I provided for nios2 linux/uclinux on nios wiki. They are used by many nios2 users.
It may be used by other boards which support the GPIO access conventions of Linux. Though the GPIO access is not unified in u-boot currently, I think it should be the right direction to follow the conventions of Linux.
I mean, which board in U-Boot uses this code? I didn't find any.
The convention is not to add unused code. If there are no real users for this, the patch should be delayed until a board gets added that actually uses it.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You are an excellent tactician, Captain. You let your second in com- mand attack while you sit and watch for weakness. -- Khan Noonian Singh, "Space Seed", stardate 3141.9
PATCH v2 1/1 misc: add gpio based status led driver
Quoted 8 lines · Wolfgang Denk
I mean, which board in U-Boot uses this code? I didn't find any.
The convention is not to add unused code. If there are no real users for this, the patch should be delayed until a board gets added that actually uses it.
Hi Wolfgang,
These nios2 boards are now supported with the nios2-generic board approach, like that of microblaze-generic, instead of adding every nios2 board to u-boot mainline. The nios2-generic board patch was applied to Scott's next branch.
The gpio led can be enabled with the following added to the board config file.
/*
* STATUS LED
*/
#define CONFIG_STATUS_LED /* Enable status driver */
#define CONFIG_GPIO_LED /* Enable gpio led driver */
#define STATUS_LED_BIT 2 /* Bit-2 on GPIO */
#define STATUS_LED_STATE 1 /* Blinking */
#define STATUS_LED_PERIOD (500 / CONFIG_SYS_NIOS_TMRMS) /* 500 msec */
Cheers,
Thomas
PATCH v2 1/1 misc: add gpio based status led driver
Hi Wolfgang,
Quoted 3 lines · Thomas Chou
Quoted 2 lines · Wolfgang Denk
I mean, which board in U-Boot uses this code? I didn't find any.
I think the most accurate answer is both "all" and "none" ... and I'm not trying to be funny or disrespectful in any way. It's just so very easy to replace peripherals with these FPGA based systems.
Quoted 4 lines
Quoted 4 lines
The convention is not to add unused code. If there are no real users for this, the patch should be delayed until a board gets added that actually uses it.
My understanding is that the nios2 linux folks make use of the peripheral that this driver supports. However, the peripheral is not a standard Altera peripheral. In any case, it can essentially be used on any nios2 board as a replacement for the stock PIO peripheral.
Quoted 4 lines
These nios2 boards are now supported with the nios2-generic board approach, like that of microblaze-generic, instead of adding every nios2 board to u-boot mainline. The nios2-generic board patch was applied to Scott's next branch.
Correct. I asked Thomas to remove this peripheral from the Altera board tree because it was not associated with a _standard_ Altera peripheral. That is, anyone using the default configurations from Altera will never use this driver.
However, the nios2 linux folks are very likely to use it (as a replacement). And, when they build u-boot, it will probably be configured using the nios2-generic board. So this isn't a rabbit in the hat ... the code will used. It's just not directly tied to a particular PCB from a traditional point of view.
Regards,
--Scott
PATCH v2 1/1 misc: add gpio based status led driver
Dear Scott McNutt,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Quoted 2 lines
I mean, which board in U-Boot uses this code? I didn't find any.
I think the most accurate answer is both "all" and "none" ... and I'm not trying to be funny or disrespectful in any way. It's just so very easy to replace peripherals with these FPGA based systems.
Yes, but the current number of actual users so far is zero.
Quoted 5 lines
However, the nios2 linux folks are very likely to use it (as a replacement). And, when they build u-boot, it will probably be configured using the nios2-generic board. So this isn't a rabbit in the hat ... the code will used. It's just not directly tied to a particular PCB from a traditional point of view.
OK. Let's add the code when there is a user for it.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense. - E. W. Dijkstra
PATCH v2 1/1 misc: add gpio based status led driver
In reply to Thomas ChouDear Thomas Chou,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines
The convention is not to add unused code. If there are no real users for this, the patch should be delayed until a board gets added that actually uses it.
Quoted 7 lines
These nios2 boards are now supported with the nios2-generic board approach, like that of microblaze-generic, instead of adding every nios2 board to u-boot mainline. The nios2-generic board patch was applied to Scott's next branch.
The gpio led can be enabled with the following added to the board config file.
As long as no board actually uses this code we should put that patch on hold. Please resubmit it as part of the patch series that adds the first board that uses this code. Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's all Klatchian to me.
- Terry Pratchett & Stephen Briggs, _The Discworld Companion_PATCH v2 1/1 misc: add gpio based status led driver
Quoted 5 lines · Wolfgang Denk
As long as no board actually uses this code we should put that patch on hold. Please resubmit it as part of the patch series that adds the first board that uses this code. Thanks.
Hi Wolfgang,
I sent a patch to enable some peripherals on the nios2-generic board.
04/28 [PATCH v2] nios2: add epcs, gpio led and mmc_spi to nios2-generic
This patch should be applied after the other outstanding patches. Please let me know if this is all right?
Best regards,
Thomas
PATCH v2 1/1 misc: add gpio based status led driver
Dear Thomas Chou,
Quoted 6 lines · In message <[email protected]> you wrote:
I sent a patch to enable some peripherals on the nios2-generic board.
04/28 [PATCH v2] nios2: add epcs, gpio led and
mmc_spito nios2-genericThis patch should be applied after the other outstanding patches. Please let me know if this is all right?
I don't understand how this is supposed to work? How can you enable a feature that has not been added yet? Will this not cause build errors?
I guess to make sure the code remains bisectable both should be done in a single step?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You humans have that emotional need to express gratitude. "You're welcome," I believe, is the correct response. -- Spock, "Bread and Circuses", stardate 4041.2
PATCH v2 1/1 misc: add gpio based status led driver
Dear Wolfgang,
Quoted 11 lines · Wolfgang Denk
Dear Thomas Chou,
Quoted 5 lines · In message <[email protected]> you wrote:
I sent a patch to enable some peripherals on the nios2-generic board.
04/28 [PATCH v2] nios2: add epcs, gpio led and
mmc_spito nios2-genericThis patch should be applied after the other outstanding patches. Please let me know if this is all right?
I don't understand how this is supposed to work? How can you enable a feature that has not been added yet? Will this not cause build errors?
It can't. I won't. It will.
Quoted 2 lines
I guess to make sure the code remains bisectable both should be done in a single step?
I have a few patches pending in such a state -- they will not be added until the prerequisites are met.
I'd be glad to push the various prerequisite patches into a test branch ... but I've be far too busy.
Regards,
--Scott
PATCH v2 1/1 misc: add gpio based status led driver
In reply to Wolfgang DenkQuoted 13 lines · Wolfgang Denk
Dear Thomas Chou,
Quoted 6 lines · In message<[email protected]> you wrote:
I sent a patch to enable some peripherals on the nios2-generic board.
04/28 [PATCH v2] nios2: add epcs, gpio led and
mmc_spito nios2-genericThis patch should be applied after the other outstanding patches. Please let me know if this is all right?
I don't understand how this is supposed to work? How can you enable a feature that has not been added yet? Will this not cause build errors?
Quoted 8 lines
I guess to make sure the code remains bisectable both should be done in a single step?
Best regards,
Wolfgang Denk
Hi Wolfgang and Scott,
Please disregard the v2 patch on 04/28. I have resubmit the patch series in a way that they can be applied one-by-one without breaking others. I have tested the build on Altera dev boards using standard configuration.
04/30 [PATCH 0/6] add gpio_led and altera_spi drivers
nios2: add gpio support
misc: add gpio based status led driver
nios2: add gpio support to nios2-generic board
spi: add altera spi controller support
spi_flash: support old STMicro parts with RES, v3 acked by Mike Frysinger.
nios2: add spi flash support to nios2-generic board
Best regards,
Thomas
cover add gpio_led and altera_spi drivers
In reply to Wolfgang DenkThis patch series add gpio_led and altera_spi support for the nios2-generic board, which is based on the Altera EP1C20 board. It enables status LED and SPI flash access on this board. It includes the outstanding patches to complete the support.
Best regards,
Thomas
Thomas Chou (6):
nios2: add gpio support
misc: add gpio based status led driver
nios2: add gpio support to nios2-generic board
spi: add altera spi controller support
spi_flash: support old STMicro parts with RES
nios2: add spi flash support to nios2-generic board
arch/nios2/include/asm/gpio.h | 52 ++++++++++ board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/custom_fpga.h | 10 ++ board/altera/nios2-generic/gpio.c | 55 ++++++++++ drivers/misc/Makefile | 1 + drivers/misc/gpio_led.c | 30 ++++++ drivers/mtd/spi/spi_flash.c | 1 + drivers/mtd/spi/stmicro.c | 21 ++++ drivers/spi/Makefile | 1 + drivers/spi/altera_spi.c | 165 ++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 +- 11 files changed, 340 insertions(+), 3 deletions(-) create mode 100644 arch/nios2/include/asm/gpio.h create mode 100644 board/altera/nios2-generic/gpio.c create mode 100644 drivers/misc/gpio_led.c create mode 100644 drivers/spi/altera_spi.c
PATCH v4 1/6 nios2: add gpio support
In reply to Wolfgang DenkThis patch adds driver for a trivial gpio core, which is described in http://nioswiki.com/GPIO. It is used for gpio led and nand flash interface in u-boot.
When CONFIG_SYS_GPIO_BASE is not defined, board may provide its own driver.
---
v4: remove () from gpio when it is not in a macro.
v3: arch dir reorganized.
arch/nios2/include/asm/gpio.h | 52 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 arch/nios2/include/asm/gpio.h
arch/nios2/include/asm/gpio.h new file +52 -0
@@ -0,0 +1,52 @@ +/* +* nios2 gpio driver +* +* This gpio core is described in http://nioswiki.com/GPIO +* bit[0] data +* bit[1] output enable +* +* when CONFIG_SYS_GPIO_BASE is not defined, board may provide +* its own driver. +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _ASM_NIOS2_GPIO_H_ +#define _ASM_NIOS2_GPIO_H_ + +#ifdef CONFIG_SYS_GPIO_BASE +#include <asm/io.h> + +static inline int gpio_direction_input (unsigned gpio) +{ +writel (1 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +return 0 ; +} + +static inline int gpio_direction_output (unsigned gpio,int value) +{ +writel (value ?3 :2 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +return 0 ; +} + +static inline int gpio_get_value (unsigned gpio) +{ +return readl (CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +} + +static inline void gpio_set_value (unsigned gpio,int value) +{ +writel (value ?3 :2 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +} +#else +extern int gpio_direction_input (unsigned gpio); +extern int gpio_direction_output (unsigned gpio,int value); +extern int gpio_get_value (unsigned gpio); +extern void gpio_set_value (unsigned gpio,int value); +#endif /* CONFIG_SYS_GPIO_BASE */ + +#endif /* _ASM_NIOS2_GPIO_H_ */
Signature · 1 line
1.6.6.1
PATCH v4 1/6 nios2: add gpio support
Quoted 8 lines · Thomas Chou
This patch adds driver for a trivial gpio core, which is described in http://nioswiki.com/GPIO. It is used for gpio led and nand flash interface in u-boot.
When
CONFIG_SYS_GPIO_BASEis not defined, board may provide its own driver.Signed-off-by Thomas Chou <[email protected]>
Tested with LED on Altera 2C35 development board.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
PATCH v4 1/6 nios2: add gpio support
In reply to Thomas ChouApplied to:
git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Quoted 74 lines · Thomas Chou
This patch adds driver for a trivial gpio core, which is described in http://nioswiki.com/GPIO. It is used for gpio led and nand flash interface in u-boot.
When
CONFIG_SYS_GPIO_BASEis not defined, board may provide its own driver.Signed-off-by Thomas Chou <[email protected]>---
v4: remove () from gpio when it is not in a macro.
v3: arch dir reorganized.arch/nios2/include/asm/gpio.h | 52 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 arch/nios2/include/asm/gpio.harch/nios2/include/asm/gpio.h new file +52
-0@@ -0,0 +1,52 @@ +/* +* nios2 gpio driver +* +* This gpio core is described in http://nioswiki.com/GPIO +* bit[0] data +* bit[1] output enable +* +* when CONFIG_SYS_GPIO_BASE is not defined, board may provide +* its own driver. +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _ASM_NIOS2_GPIO_H_ +#define _ASM_NIOS2_GPIO_H_ + +#ifdef CONFIG_SYS_GPIO_BASE +#include <asm/io.h> + +static inline int gpio_direction_input (unsigned gpio) +{ +writel (1 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +return 0 ; +} + +static inline int gpio_direction_output (unsigned gpio,int value) +{ +writel (value ?3 :2 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +return 0 ; +} + +static inline int gpio_get_value (unsigned gpio) +{ +return readl (CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +} + +static inline void gpio_set_value (unsigned gpio,int value) +{ +writel (value ?3 :2 ,CONFIG_SYS_GPIO_BASE + (gpio <<2 )); +} +#else +extern int gpio_direction_input (unsigned gpio); +extern int gpio_direction_output (unsigned gpio,int value); +extern int gpio_get_value (unsigned gpio); +extern void gpio_set_value (unsigned gpio,int value); +#endif /* CONFIG_SYS_GPIO_BASE */ + +#endif /* _ASM_NIOS2_GPIO_H_ */
PATCH v2 2/6 misc: add gpio based status led driver
In reply to Wolfgang DenkThis patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
---
v2: moved to drivers/misc.
drivers/misc/Makefile | 1 + drivers/misc/gpio_led.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/gpio_led.c
drivers/misc/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB := $(obj)libmisc.a COBJS-$(CONFIG_ALI152X) += ali512x.o COBJS-$(CONFIG_DS4510) += ds4510.o COBJS-$(CONFIG_FSL_LAW) += fsl_law.o +COBJS-$(CONFIG_GPIO_LED) += gpio_led.o COBJS-$(CONFIG_NS87308) += ns87308.o COBJS-$(CONFIG_STATUS_LED) += status_led.o COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.o
drivers/misc/gpio_led.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Status LED driver based on GPIO access conventions of Linux +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <common.h> +#include <status_led.h> +#include <asm/gpio.h> + +/* assume led is active low */ + +void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
Signature · 1 line
1.6.6.1
PATCH v2 2/6 misc: add gpio based status led driver
Quoted 4 lines · Thomas Chou
This patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou <[email protected]>
Tested on Altera 2C35 development board.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
PATCH v2 2/6 misc: add gpio based status led driver
In reply to Thomas ChouApplied to:
git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Quoted 60 lines · Thomas Chou
This patch adds a status led driver followed the GPIO access conventions of Linux. The led mask is used to specify the gpio pin.
Signed-off-by Thomas Chou <[email protected]>---
v2: moved todrivers/misc.drivers/misc/Makefile | 1 + drivers/misc/gpio_led.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/gpio_led.cdrivers/misc/Makefile +1
-0@@ -28,6 +28,7 @@ LIB := $(obj)libmisc.a COBJS-$(CONFIG_ALI152X) += ali512x.o COBJS-$(CONFIG_DS4510) += ds4510.o COBJS-$(CONFIG_FSL_LAW) += fsl_law.o +COBJS-$(CONFIG_GPIO_LED) += gpio_led.o COBJS-$(CONFIG_NS87308) += ns87308.o COBJS-$(CONFIG_STATUS_LED) += status_led.o COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.odrivers/misc/gpio_led.c new file +30
-0@@ -0,0 +1,30 @@ +/* +* Status LED driver based on GPIO access conventions of Linux +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <common.h> +#include <status_led.h> +#include <asm/gpio.h> + +/* assume led is active low */ + +void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
In reply to Wolfgang DenkThis patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only gpio_led at the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.
---
v3: split patches for gpio and spi, based gpio on altera pio core.
v2: remove mmc_spi_init()
board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 board/altera/nios2-generic/gpio.c
board/altera/nios2-generic/Makefile +1 -0
@@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a COBJS-y := $(BOARD).o COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o COBJS-$(CONFIG_EPLED) += ../common/epled.o +COBJS-$(CONFIG_GPIO) += gpio.o COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.o SOBJS-y := text_base.o
board/altera/nios2-generic/gpio.c new file +55 -0
55 lines not on this page · raw message
include/configs/nios2-generic.h +3 -3
@@ -63,10 +63,10 @@* STATUS LED */ #define CONFIG_STATUS_LED /* Enable status driver */ -#define CONFIG_EPLED /* Enable LED PIO driver */ -#define CONFIG_SYS_LEDPIO_ADDR LED_PIO_BASE +#define CONFIG_GPIO_LED /* Enable GPIO LED driver */ +#define CONFIG_GPIO /* Enable GPIO driver */ -#define STATUS_LED_BIT 1/* Bit-0 on PIO */ +#define STATUS_LED_BIT 0/* Bit-0 on GPIO */ #define STATUS_LED_STATE 1/* Blinking */ #define STATUS_LED_PERIOD (500 / CONFIG_SYS_NIOS_TMRMS)/* 500 msec */
Signature · 1 line
1.6.6.1
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
Quoted 21 lines · Thomas Chou
This patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only
gpio_ledat the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.Signed-off-by Thomas Chou <[email protected]>---
v3: split patches for gpio and spi, based gpio on altera pio core.
v2: removemmc_spi_init()board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 board/altera/nios2-generic/gpio.cboard/altera/nios2-generic/Makefile +0
-0
board/altera/nios2-generic/Makefile LIB = $(obj)lib$(BOARD).a · line 36
Quoted 5 lines
board/altera/nios2-generic/Makefile +1
-0@@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a COBJS-y := $(BOARD).o COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o COBJS-$(CONFIG_EPLED) += ../common/epled.o +COBJS-$(CONFIG_GPIO) += gpio.o COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.o
This will build a u-boot image that will not work with any of the standard configurations ... correct? ... since the GPIO component is custom (not supplied by the vendor)?
--Scott
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
Quoted 18 lines · Scott McNutt
Quoted 17 lines · Thomas Chou
This patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only
gpio_ledat the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.Signed-off-by Thomas Chou <[email protected]>---
v3: split patches for gpio and spi, based gpio on altera pio core.
v2: removemmc_spi_init()board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 board/altera/nios2-generic/gpio.c
Quoted 16 lines
board/altera/nios2-generic/Makefile LIB = $(obj)lib$(BOARD).a · line 36
Quoted 11 lines
board/altera/nios2-generic/Makefile +1
-0@@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a COBJS-y := $(BOARD).o COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o COBJS-$(CONFIG_EPLED) += ../common/epled.o +COBJS-$(CONFIG_GPIO) += gpio.o COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.oThis will build a u-boot image that will not work with any of the standard configurations ... correct? ... since the GPIO component is custom (not supplied by the vendor)?
Hi Scott,
The board gpio.c driver works on Altera PIO component. It will behave exactly the same as the epled driver. I have tested it on EP1C20 an EP2C35 board with standard configuration. I believe it will work with the standard configuration on EP1S10 and EP1S40. I don't want to break anything.
It was actually the first gpio driver I wrote for nios2-linux before the custom gpio core.
Best regards,
Thomas
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
Quoted 35 lines · Thomas Chou
Quoted 18 lines · Scott McNutt
Quoted 17 lines · Thomas Chou
This patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only
gpio_ledat the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.Signed-off-by Thomas Chou <[email protected]>---
v3: split patches for gpio and spi, based gpio on altera pio core.
v2: removemmc_spi_init()board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 board/altera/nios2-generic/gpio.cQuoted 16 lines
board/altera/nios2-generic/Makefile LIB = $(obj)lib$(BOARD).a · line 36
Quoted 11 lines
board/altera/nios2-generic/Makefile +1
-0@@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a COBJS-y := $(BOARD).o COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o COBJS-$(CONFIG_EPLED) += ../common/epled.o +COBJS-$(CONFIG_GPIO) += gpio.o COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.oThis will build a u-boot image that will not work with any of the standard configurations ... correct? ... since the GPIO component is custom (not supplied by the vendor)?
Quoted 7 lines
Hi Scott,
The board
gpio.cdriver works on Altera PIO component. It will behave exactly the same as the epled driver. I have tested it on EP1C20 an EP2C35 board with standard configuration. I believe it will work with the standard configuration on EP1S10 and EP1S40. I don't want to break anything.
Ok. I'll try to test over the weekend as well.
Thanks,
--Scott
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
In reply to Thomas ChouQuoted 6 lines · Thomas Chou
This patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only
gpio_ledat the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.Signed-off-by Thomas Chou <[email protected]>
Tested with LED on Altera 2C35 development board.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
PATCH v3 3/6 nios2: add gpio support to nios2-generic board
In reply to Thomas ChouApplied to:
git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Quoted 107 lines · Thomas Chou
This patch adds gpio support of Altera PIO component to the nios2-generic board. Though it drives only
gpio_ledat the moment, it supports bidirectional port to control bit-banging I2C, NAND flash busy status or button switches, etc.Signed-off-by Thomas Chou <[email protected]>---
v3: split patches for gpio and spi, based gpio on altera pio core.
v2: removemmc_spi_init()board/altera/nios2-generic/Makefile | 1 + board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 6 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 board/altera/nios2-generic/gpio.cboard/altera/nios2-generic/Makefile +1
-0@@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a COBJS-y := $(BOARD).o COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o COBJS-$(CONFIG_EPLED) += ../common/epled.o +COBJS-$(CONFIG_GPIO) += gpio.o COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.o SOBJS-y := text_base.oboard/altera/nios2-generic/gpio.c new file +55
-0@@ -0,0 +1,55 @@ +/* +* board gpio driver +* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* Licensed under the GPL-2 or later. +*/ +#include <common.h> +#include <asm/io.h> + +#ifndef CONFIG_SYS_GPIO_BASE + +#define ALTERA_PIO_BASE LED_PIO_BASE +#define ALTERA_PIO_DATA (ALTERA_PIO_BASE + 0) +#define ALTERA_PIO_DIR (ALTERA_PIO_BASE + 4) +static u32 pio_data_reg; +static u32 pio_dir_reg; + +int gpio_direction_input (unsigned gpio) +{ +u32 mask =1 << gpio; +writel (pio_dir_reg &= ~mask,ALTERA_PIO_DIR ); +return 0 ; +} + +int gpio_direction_output (unsigned gpio,int value) +{ +u32 mask =1 << gpio; +if (value) + pio_data_reg |= mask; +else + pio_data_reg &= ~mask; +writel (pio_data_reg,ALTERA_PIO_DATA ); +writel (pio_dir_reg |= mask,ALTERA_PIO_DIR ); +return 0 ; +} + +int gpio_get_value (unsigned gpio) +{ +u32 mask =1 << gpio; +if (pio_dir_reg & mask) +return (pio_data_reg & mask) ?1 :0 ; +else +return (readl (ALTERA_PIO_DATA ) & mask) ?1 :0 ; +} + +void gpio_set_value (unsigned gpio,int value) +{ +u32 mask =1 << gpio; +if (value) + pio_data_reg |= mask; +else + pio_data_reg &= ~mask; +writel (pio_data_reg,ALTERA_PIO_DATA ); +} +#endif include/configs/nios2-generic.h +3
-3@@ -63,10 +63,10 @@* STATUS LED */ #define CONFIG_STATUS_LED /* Enable status driver */ -#define CONFIG_EPLED /* Enable LED PIO driver */ -#define CONFIG_SYS_LEDPIO_ADDR LED_PIO_BASE +#define CONFIG_GPIO_LED /* Enable GPIO LED driver */ +#define CONFIG_GPIO /* Enable GPIO driver */ -#define STATUS_LED_BIT 1/* Bit-0 on PIO */ +#define STATUS_LED_BIT 0/* Bit-0 on GPIO */ #define STATUS_LED_STATE 1/* Blinking */ #define STATUS_LED_PERIOD (500 / CONFIG_SYS_NIOS_TMRMS)/* 500 msec */
PATCH v10 4/6 spi: add altera spi controller support
In reply to Wolfgang DenkThis patch adds the driver of altera spi controller, which is used as epcs/spi flash controller. It also works with mmc_spi driver.
This driver support more than one spi bus, with base list declared #define CONFIG_SYS_ALTERA_SPI_LIST { BASE_0,BASE_1,... }
---
v10 remove bus check in setup slave, as spi_cs_is_valid() did it. v9 check bus in spi_cs_is_valid().
v8 fix cs activate timing.
v7 add cs activate deactive to work with legacy spi_mmc driver. v6 wrong patch, same as v5.
v5 tabify.
drivers/spi/Makefile | 1 + drivers/spi/altera_spi.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/altera_spi.c
drivers/spi/Makefile +1 -0
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libspi.a +COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
drivers/spi/altera_spi.c new file +165 -0
165 lines not on this page · raw message
Signature · 1 line
1.6.6.1
PATCH v10 4/6 spi: add altera spi controller support
Quoted 8 lines · Thomas Chou
This patch adds the driver of altera spi controller, which is used as epcs/spi flash controller. It also works with
mmc_spidriver.This driver support more than one spi bus, with base list declared #define
CONFIG_SYS_ALTERA_SPI_LIST{ BASE_0,BASE_1,... }Signed-off-by Thomas Chou <[email protected]>
Tested with EPCS64N flash chip on Altera 2C35 development board.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
PATCH v10 4/6 spi: add altera spi controller support
In reply to Thomas ChouApplied to:
git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Quoted 204 lines · Thomas Chou
This patch adds the driver of altera spi controller, which is used as epcs/spi flash controller. It also works with
mmc_spidriver.This driver support more than one spi bus, with base list declared #define
CONFIG_SYS_ALTERA_SPI_LIST{ BASE_0,BASE_1,... }Signed-off-by Thomas Chou <[email protected]>---
v10 remove bus check in setup slave, asspi_cs_is_valid()did it. v9 check bus inspi_cs_is_valid().
v8 fix cs activate timing.
v7 add cs activate deactive to work with legacyspi_mmcdriver. v6 wrong patch, same as v5.
v5 tabify.drivers/spi/Makefile | 1 + drivers/spi/altera_spi.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/altera_spi.cdrivers/spi/Makefile +1
-0@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libspi.a +COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.odrivers/spi/altera_spi.c new file +165
-0@@ -0,0 +1,165 @@ +/* +* Altera SPI driver +* +* based on bfin_spi.c +* Copyright (c) 2005-2008 Analog Devices Inc. +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* Licensed under the GPL-2 or later. +*/ +#include <common.h> +#include <asm/io.h> +#include <malloc.h> +#include <spi.h> + +#define ALTERA_SPI_RXDATA 0 +#define ALTERA_SPI_TXDATA 4 +#define ALTERA_SPI_STATUS 8 +#define ALTERA_SPI_CONTROL 12 +#define ALTERA_SPI_SLAVE_SEL 20 + +#define ALTERA_SPI_STATUS_ROE_MSK (0x8) +#define ALTERA_SPI_STATUS_TOE_MSK (0x10) +#define ALTERA_SPI_STATUS_TMT_MSK (0x20) +#define ALTERA_SPI_STATUS_TRDY_MSK (0x40) +#define ALTERA_SPI_STATUS_RRDY_MSK (0x80) +#define ALTERA_SPI_STATUS_E_MSK (0x100) + +#define ALTERA_SPI_CONTROL_IROE_MSK (0x8) +#define ALTERA_SPI_CONTROL_ITOE_MSK (0x10) +#define ALTERA_SPI_CONTROL_ITRDY_MSK (0x40) +#define ALTERA_SPI_CONTROL_IRRDY_MSK (0x80) +#define ALTERA_SPI_CONTROL_IE_MSK (0x100) +#define ALTERA_SPI_CONTROL_SSO_MSK (0x400) + +#ifndef CONFIG_SYS_ALTERA_SPI_LIST +#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE } +#endif + +static ulong altera_spi_base_list[] =CONFIG_SYS_ALTERA_SPI_LIST ; + +struct altera_spi_slave { +struct spi_slave slave; +ulong base; +}; +#define to_altera_spi_slave (s) container_of(s, struct altera_spi_slave, slave) + +__attribute__((weak)) +int spi_cs_is_valid (unsigned int bus,unsigned int cs) +{ +return bus <ARRAY_SIZE (altera_spi_base_list) && cs <32 ; +} + +__attribute__((weak)) +void spi_cs_activate (struct spi_slave *slave) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); +writel (1 << slave->cs, altspi->base +ALTERA_SPI_SLAVE_SEL ); +writel (ALTERA_SPI_CONTROL_SSO_MSK , altspi->base +ALTERA_SPI_CONTROL ); +} + +__attribute__((weak)) +void spi_cs_deactivate (struct spi_slave *slave) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); +writel (0 , altspi->base +ALTERA_SPI_CONTROL ); +writel (0 , altspi->base +ALTERA_SPI_SLAVE_SEL ); +} + +void spi_init (void ) +{ +} + +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, +unsigned int max_hz,unsigned int mode) +{ +struct altera_spi_slave *altspi; + +if (!spi_cs_is_valid (bus, cs)) +return NULL ; + + altspi =malloc (sizeof (*altspi)); +if (!altspi) +return NULL ; + + altspi->slave.bus = bus; + altspi->slave.cs = cs; + altspi->base = altera_spi_base_list[bus]; +debug ("%s: bus:%i cs:%i base:%lx\n" , __func__, + bus, cs, altspi->base); + +return &altspi->slave; +} + +void spi_free_slave (struct spi_slave *slave) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); +free (altspi); +} + +int spi_claim_bus (struct spi_slave *slave) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, slave->bus, slave->cs); +writel (0 , altspi->base +ALTERA_SPI_CONTROL ); +writel (0 , altspi->base +ALTERA_SPI_SLAVE_SEL ); +return 0 ; +} + +void spi_release_bus (struct spi_slave *slave) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); + +debug ("%s: bus:%i cs:%i\n" , __func__, slave->bus, slave->cs); +writel (0 , altspi->base +ALTERA_SPI_SLAVE_SEL ); +} + +#ifndef CONFIG_ALTERA_SPI_IDLE_VAL +# define CONFIG_ALTERA_SPI_IDLE_VAL 0xff +#endif + +int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, +void *din,unsigned long flags) +{ +struct altera_spi_slave *altspi =to_altera_spi_slave (slave); +/* assume spi core configured to do 8 bit transfers */ +uint bytes = bitlen /8 ; +const uchar *txp = dout; +uchar *rxp = din; + +debug ("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n" , __func__, + slave->bus, slave->cs, bitlen, bytes, flags); +if (bitlen ==0 ) + goto done; + +if (bitlen %8 ) { + flags |=SPI_XFER_END ; + goto done; + } + +/* empty read buffer */ +if (readl (altspi->base +ALTERA_SPI_STATUS ) & +ALTERA_SPI_STATUS_RRDY_MSK ) +readl (altspi->base +ALTERA_SPI_RXDATA ); +if (flags &SPI_XFER_BEGIN ) +spi_cs_activate (slave); + +while (bytes--) { +uchar d = txp ? *txp++ :CONFIG_ALTERA_SPI_IDLE_VAL ; +debug ("%s: tx:%x " , __func__, d); +writel (d, altspi->base +ALTERA_SPI_TXDATA ); +while (!(readl (altspi->base +ALTERA_SPI_STATUS ) & +ALTERA_SPI_STATUS_RRDY_MSK )) + ; + d =readl (altspi->base +ALTERA_SPI_RXDATA ); +if (rxp) + *rxp++ = d; +debug ("rx:%x\n" , d); + } + done: +if (flags &SPI_XFER_END ) +spi_cs_deactivate (slave); + +return 0 ; +}
PATCH v2 5/6 spi_flash: support old STMicro parts with RES
In reply to Wolfgang DenkSome old STMicro parts do not support JEDEC ID (0x9f). This patch uses RES (0xab) to get Electronic ID and translates it to JEDEC ID. This is needed to support the SPI flash chip on Altera EP1C20 board.
---
v2: move the logic to stmicro's probe function.
drivers/mtd/spi/spi_flash.c | 1 + drivers/mtd/spi/stmicro.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/spi/spi_flash.c +1 -0
@@ -147,6 +147,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,#endif #ifdef CONFIG_SPI_FLASH_STMICRO case 0x20 : +case 0xff : flash =spi_flash_probe_stmicro (spi, idcode);break ;#endif
drivers/mtd/spi/stmicro.c +21 -0
@@ -46,6 +46,7 @@#define CMD_M25PXX_DP 0xb9/* Deep Power-down */ #define CMD_M25PXX_RES 0xab/* Release from DP, and Read Signature */ +#define STM_ID_M25P10 0x11#define STM_ID_M25P16 0x15#define STM_ID_M25P20 0x12#define STM_ID_M25P32 0x16
@@ -78,6 +79,13 @@ static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flashstatic const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = { { + .idcode1 =STM_ID_M25P10 , + .page_size =256 , + .pages_per_sector =128 , + .nr_sectors =4 , + .name ="M25P10" , + }, + { .idcode1 =STM_ID_M25P16 , .page_size =256 , .pages_per_sector =256 ,
@@ -316,6 +324,19 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)struct stmicro_spi_flash *stm;unsigned int i; +if (idcode[0 ] ==0xff ) { + i =spi_flash_cmd (spi,CMD_M25PXX_RES , + idcode,4 ); +if (i) +return NULL ; +if ((idcode[3 ] &0xf0 ) ==0x10 ) { + idcode[0 ] =0x20 ; + idcode[1 ] =0x20 ; + idcode[2 ] = idcode[3 ] +1 ; + }else +return NULL ; + } +for (i =0 ; i <ARRAY_SIZE (stmicro_spi_flash_table); i++) { params = &stmicro_spi_flash_table[i];if (params->idcode1 == idcode[2 ]) {
Signature · 1 line
1.6.6.1
PATCH v2 5/6 spi_flash: support old STMicro parts with RES
drivers/mtd/spi/spi_flash.c struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, · line 153
Quoted 10 lines · On Thursday 29 April 2010 23:34:17 Thomas Chou wrote:
drivers/mtd/spi/spi_flash.c +0
-0@@ -147,6 +147,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus,unsigned int cs, #endif
#ifdefCONFIG_SPI_FLASH_STMICROdrivers/mtd/spi/spi_flash.c +1
-0case 0x20 : +case 0xff : flash =spi_flash_probe_stmicro (spi, idcode);break ;#endif
hrm, this kind of sucks, but i guess for now it's fine. stick a comment in there about why we're sending the normal error byte to the stmicro function.
/* Let the stmicro func handle non-JEDEC ids */
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100430/c3f1e88b/attachment.pgp
PATCH v2 5/6 spi_flash: support old STMicro parts with RES
Quoted 15 lines · Mike Frysinger
drivers/mtd/spi/spi_flash.c struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, · line 153
Quoted 11 lines · On Thursday 29 April 2010 23:34:17 Thomas Chou wrote:
drivers/mtd/spi/spi_flash.c +0
-0@@ -147,6 +147,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus,unsigned int cs, #endif
#ifdefCONFIG_SPI_FLASH_STMICRO
case0x20:drivers/mtd/spi/spi_flash.c +1
-0+case 0xff : flash =spi_flash_probe_stmicro (spi, idcode);break ;#endif hrm, this kind of sucks, but i guess for now it's fine. stick a comment in there about why we're sending the normal error byte to the stmicro function.
Quoted 3 lines
/* Let the stmicro func handle non-JEDEC ids */-mike
Hi Mike,
I added the comment. Thank you very much.
Best regards,
Thomas
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
In reply to Thomas ChouSome old STMicro parts do not support JEDEC ID (0x9f). This patch uses RES (0xab) to get Electronic ID and translates it to JEDEC ID.
---
v3: add comment as Mike suggested for 0xff id switch.
v2: move the logic to stmicro's probe function
drivers/mtd/spi/spi_flash.c | 1 + drivers/mtd/spi/stmicro.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/spi/spi_flash.c +1 -0
@@ -147,6 +147,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,#endif #ifdef CONFIG_SPI_FLASH_STMICRO case 0x20 : +case 0xff :/* Let the stmicro func handle non-JEDEC ids */ flash =spi_flash_probe_stmicro (spi, idcode);break ;#endif
drivers/mtd/spi/stmicro.c +21 -0
@@ -46,6 +46,7 @@#define CMD_M25PXX_DP 0xb9/* Deep Power-down */ #define CMD_M25PXX_RES 0xab/* Release from DP, and Read Signature */ +#define STM_ID_M25P10 0x11#define STM_ID_M25P16 0x15#define STM_ID_M25P20 0x12#define STM_ID_M25P32 0x16
@@ -78,6 +79,13 @@ static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flashstatic const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = { { + .idcode1 =STM_ID_M25P10 , + .page_size =256 , + .pages_per_sector =128 , + .nr_sectors =4 , + .name ="M25P10" , + }, + { .idcode1 =STM_ID_M25P16 , .page_size =256 , .pages_per_sector =256 ,
@@ -316,6 +324,19 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)struct stmicro_spi_flash *stm;unsigned int i; +if (idcode[0 ] ==0xff ) { + i =spi_flash_cmd (spi,CMD_M25PXX_RES , + idcode,4 ); +if (i) +return NULL ; +if ((idcode[3 ] &0xf0 ) ==0x10 ) { + idcode[0 ] =0x20 ; + idcode[1 ] =0x20 ; + idcode[2 ] = idcode[3 ] +1 ; + }else +return NULL ; + } +for (i =0 ; i <ARRAY_SIZE (stmicro_spi_flash_table); i++) { params = &stmicro_spi_flash_table[i];if (params->idcode1 == idcode[2 ]) {
Signature · 1 line
1.6.6.1
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
Quoted 4 lines · On Friday 30 April 2010 09:11:20 Thomas Chou wrote:
Some old STMicro parts do not support JEDEC ID (
0x9f). This patch uses RES (0xab) to get Electronic ID and translates it to JEDEC ID.Signed-off-by Thomas Chou <[email protected]>
if we want to do non-jedec stuff in other parts, we can worry about refactoring this code then
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100430/094fe126/attachment.pgp
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
In reply to Thomas Chouive merged this into my sf branch and will push out next merge window if Wolfgang doesnt pick it up before that
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100505/9e5d6405/attachment.pgp
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
Quoted 4 lines · Mike Frysinger
ive merged this into my sf branch and will push out next merge window if Wolfgang doesnt pick it up before that
-mike
Hi Mike,
You are so nice. Thanks again.
Best regards,
Thomas
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
ive merged this into my sf branch and will push out next merge window if Wolfgang doesnt pick it up before that
Just let me know what you (and Thomas) prefer, and what exactly (which patch[es] from this series) the "it" is that should be picked up (or not).
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Gods don't like people not doing much work. People who aren't busy all the time might start to _think_. - Terry Pratchett, _Small Gods_
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
Quoted 5 lines · On Wednesday 05 May 2010 15:57:29 Wolfgang Denk wrote:
Quoted 2 lines · Mike Frysinger
ive merged this into my sf branch and will push out next merge window if Wolfgang doesnt pick it up before that
Just let me know what you (and Thomas) prefer
doesnt matter to me whether you pull my branch now or after the merge window:
git://git.denx.de/u-boot-blackfin.git sf
Quoted 2 lines
and what exactly (which patch[es] from this series) the "it" is that should be picked up (or not).
there is only one patch in this thread ...
referring to all the patches in my branch, none are "bugfixes" persay which is why i didnt know if you wanted to let them sit until next merge window. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100505/3714b67e/attachment.pgp
PATCH v3 5/6 spi_flash: support old STMicro parts with RES
In reply to Wolfgang DenkDear Wolfgang,
Quoted 12 lines · Wolfgang Denk
Dear Mike Frysinger,
Quoted 3 lines · In message<[email protected]> you wrote:
ive merged this into my sf branch and will push out next merge window if Wolfgang doesnt pick it up before that
Just let me know what you (and Thomas) prefer, and what exactly (which patch[es] from this series) the "it" is that should be picked up (or not).
These patches were submitted within this merge window. I just resubmitted the outstanding patches in a series as you suggested. It would be nice if you can merge them in this release. The current u-boot supports only very old, obsolete Altera dev boards, most newer boards are not supported. I hope we can work together to let these patches merged, so that most Altera's dev boards can be supported.
The drivers for gpio, altera_spi, spi_flash and mmc_spi are important as Altera includes them in their example design.
Best regards,
Thomas
PATCH v3 6/6 nios2: add spi flash support to nios2-generic board
In reply to Wolfgang DenkThis patch enables the altera_spi and spi_flash drivers for the nios2-generic board. It allows access to the EPCS/SPI flash on the Altera EP1C20 board.
---
v3: split patches for gpio and spi.
v2: remove mmc_spi_init()
board/altera/nios2-generic/custom_fpga.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
board/altera/nios2-generic/custom_fpga.h +10 -0
@@ -35,6 +35,16 @@#define CONFIG_SMC91111 #define CONFIG_SMC_USE_32_BIT +/* epcs_controller.epcs_control_port is a altera_avalon_epcs_flash_controller */ +#define EPCS_CONTROLLER_REG_BASE 0x82100200 +#define CONFIG_SYS_ALTERA_SPI_LIST { EPCS_CONTROLLER_REG_BASE } +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO +/* jtag_uart.avalon_jtag_slave is a altera_avalon_jtag_uart */ #define CONFIG_SYS_JTAG_UART_BASE 0x821208b0
Signature · 1 line
1.6.6.1
PATCH v3 6/6 nios2: add spi flash support to nios2-generic board
Quoted 5 lines · Thomas Chou
This patch enables the
altera_spiandspi_flashdrivers for the nios2-generic board. It allows access to the EPCS/SPI flash on the Altera EP1C20 board.Signed-off-by Thomas Chou <[email protected]>
Tested with EPCS64N flash chip on Altera 2C35 development board.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
PATCH v3 6/6 nios2: add spi flash support to nios2-generic board
In reply to Thomas ChouThomas,
I applied this to:
git://git.denx.de/u-boot-nios.git testing
after merging with Mike's 'sf' branch at:
git://git.denx.de/u-boot-blackfin
so we can pickup:
[PATCH 5/6 v3] spi_flash: support old STMicro parts with RES
I'll merge once Mike's changes are available upstream. In the meantime, the nios testing branch has the entire patch series available.
Regards,
--Scott
Quoted 33 lines · Thomas Chou
This patch enables the
altera_spiandspi_flashdrivers for the nios2-generic board. It allows access to the EPCS/SPI flash on the Altera EP1C20 board.Signed-off-by Thomas Chou <[email protected]>---
v3: split patches for gpio and spi.
v2: removemmc_spi_init()board/altera/nios2-generic/custom_fpga.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)board/altera/nios2-generic/custom_fpga.h +10
-0@@ -35,6 +35,16 @@#define CONFIG_SMC91111 #define CONFIG_SMC_USE_32_BIT +/* epcs_controller.epcs_control_port is a altera_avalon_epcs_flash_controller */ +#define EPCS_CONTROLLER_REG_BASE 0x82100200 +#define CONFIG_SYS_ALTERA_SPI_LIST { EPCS_CONTROLLER_REG_BASE } +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO +/* jtag_uart.avalon_jtag_slave is a altera_avalon_jtag_uart */ #define CONFIG_SYS_JTAG_UART_BASE 0x821208b0
PATCH 1/1 nios2: add epcs, gpio led and mmc_spi to nios2-generic
In reply to Thomas ChouSince Wolfgang requests that new driver should be used with a board, these peripherals are added to the nios2-generic board.
It will exercise drivers in these outstanding patches, 04/17 [PATCH v4] nios2: add gpio support
04/21 [PATCH v2] misc: add gpio based status led driver 04/27 [PATCH v8] spi: add altera spi controller support 04/27 [PATCH v3] mmc: add generic mmc spi driver
--- board/altera/nios2-generic/custom_fpga.h | 29 ++++++++++++++++++++++++++++ board/altera/nios2-generic/nios2-generic.c | 13 ++++++++++++ include/configs/nios2-generic.h | 9 ++++++- 3 files changed, 49 insertions(+), 2 deletions(-)
board/altera/nios2-generic/custom_fpga.h +29 -0
@@ -63,4 +63,33 @@/* sysid.control_slave is a altera_avalon_sysid */ #define CONFIG_SYS_SYSID_BASE 0x821208b8 +/* epcs_controller.epcs_control_port is a altera_avalon_epcs_flash_controller */ +#define CONFIG_SYS_SPI_BASE 0x82100200 +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO + +/* gpio_0.avalon_slave_0 is a gpio */ +#define CONFIG_SYS_GPIO_BASE 0x82120900 + +/* mmc_spi.spi_control_port is a altera_avalon_spi */ +#define MMC_SPI_BASE 0x82120940 +#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE, MMC_SPI_BASE } +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_MMC +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_CMD_MMC_SPI +#define CONFIG_MMC_SPI +#define CONFIG_MMC_SPI_BUS 1 +#define CONFIG_MMC_SPI_CS 0 +#define CONFIG_MMC_SPI_SPEED 30000000 +#define CONFIG_MMC_SPI_MODE SPI_MODE_3 +#define CONFIG_CMD_FAT +#define CONFIG_DOS_PARTITION +#endif /* _CUSTOM_FPGA_H_ */
board/altera/nios2-generic/nios2-generic.c +13 -0
@@ -24,6 +24,7 @@#include <common.h> #include <netdev.h> +#include <mmc_spi.h> void text_base_hook (void );/* nop hook for text_base.S */
@@ -66,3 +67,15 @@ int board_eth_init(bd_t *bis) return rc; }#endif + +#ifdef CONFIG_GENERIC_MMC +int board_mmc_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_MMC_SPI + rc =mmc_spi_init (CONFIG_MMC_SPI_BUS ,CONFIG_MMC_SPI_CS , +CONFIG_MMC_SPI_SPEED ,CONFIG_MMC_SPI_MODE ); +#endif +return rc; +} +#endif
include/configs/nios2-generic.h +7 -2
@@ -63,6 +63,7 @@* STATUS LED */ #define CONFIG_STATUS_LED /* Enable status driver */ +#undef CONFIG_GPIO_LED/* Enable GPIO LED driver */ #define CONFIG_EPLED /* Enable LED PIO driver */ #define CONFIG_SYS_LEDPIO_ADDR LED_PIO_BASE
@@ -108,7 +109,7 @@#define CONFIG_ENV_SIZE 0x10000/* 64k, 1 sector */ #define CONFIG_ENV_OVERWRITE /* Serial change Ok */ #define CONFIG_ENV_ADDR ((CONFIG_SYS_RESET_ADDR + \ - CONFIG_SYS_MONITOR_LEN) | \ + 0x40000) | \ CONFIG_SYS_FLASH_BASE)/*
@@ -119,7 +120,11 @@* -The stack is placed below global data (&grows down). */ #define CONFIG_MONITOR_IS_IN_RAM -#define CONFIG_SYS_MONITOR_LEN 0x40000/* Reserve 256k */ +#if defined(CONFIG_CMD_FAT ) +# define CONFIG_SYS_MONITOR_LEN 0x80000/* Reserve 512k */ +#else +# define CONFIG_SYS_MONITOR_LEN 0x40000/* Reserve 256k */ +#endif #define CONFIG_SYS_MONITOR_BASE (CONFIG_SYS_SDRAM_BASE + \ CONFIG_SYS_SDRAM_SIZE - \ CONFIG_SYS_MONITOR_LEN)
Signature · 1 line
1.6.6.1
PATCH v2 1/1 nios2: add epcs, gpio led and mmc_spi to nios2-generic
Since Wolfgang requests that new driver should be used with a board, these peripherals are added to the nios2-generic board.
It will exercise drivers in these outstanding patches, 04/17 [PATCH v4] nios2: add gpio support
04/21 [PATCH v2] misc: add gpio based status led driver 04/28 [PATCH v9] spi: add altera spi controller support 04/28 [PATCH v4] mmc: add generic mmc spi driver
---
v2 remove mmc_spi_init() from nios2-generic.c.
board/altera/nios2-generic/custom_fpga.h | 29 +++++++++++++++++++++++++++++ include/configs/nios2-generic.h | 9 +++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)
board/altera/nios2-generic/custom_fpga.h +29 -0
@@ -63,4 +63,33 @@/* sysid.control_slave is a altera_avalon_sysid */ #define CONFIG_SYS_SYSID_BASE 0x821208b8 +/* epcs_controller.epcs_control_port is a altera_avalon_epcs_flash_controller */ +#define CONFIG_SYS_SPI_BASE 0x82100200 +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO + +/* gpio_0.avalon_slave_0 is a gpio */ +#define CONFIG_SYS_GPIO_BASE 0x82120900 + +/* mmc_spi.spi_control_port is a altera_avalon_spi */ +#define MMC_SPI_BASE 0x82120940 +#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE, MMC_SPI_BASE } +#define CONFIG_ALTERA_SPI +#define CONFIG_CMD_SPI +#define CONFIG_CMD_MMC +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_CMD_MMC_SPI +#define CONFIG_MMC_SPI +#define CONFIG_MMC_SPI_BUS 1 +#define CONFIG_MMC_SPI_CS 0 +#define CONFIG_MMC_SPI_SPEED 30000000 +#define CONFIG_MMC_SPI_MODE SPI_MODE_3 +#define CONFIG_CMD_FAT +#define CONFIG_DOS_PARTITION +#endif /* _CUSTOM_FPGA_H_ */
include/configs/nios2-generic.h +7 -2
@@ -63,6 +63,7 @@* STATUS LED */ #define CONFIG_STATUS_LED /* Enable status driver */ +#undef CONFIG_GPIO_LED/* Enable GPIO LED driver */ #define CONFIG_EPLED /* Enable LED PIO driver */ #define CONFIG_SYS_LEDPIO_ADDR LED_PIO_BASE
@@ -108,7 +109,7 @@#define CONFIG_ENV_SIZE 0x10000/* 64k, 1 sector */ #define CONFIG_ENV_OVERWRITE /* Serial change Ok */ #define CONFIG_ENV_ADDR ((CONFIG_SYS_RESET_ADDR + \ - CONFIG_SYS_MONITOR_LEN) | \ + 0x40000) | \ CONFIG_SYS_FLASH_BASE)/*
@@ -119,7 +120,11 @@* -The stack is placed below global data (&grows down). */ #define CONFIG_MONITOR_IS_IN_RAM -#define CONFIG_SYS_MONITOR_LEN 0x40000/* Reserve 256k */ +#if defined(CONFIG_CMD_FAT ) +# define CONFIG_SYS_MONITOR_LEN 0x80000/* Reserve 512k */ +#else +# define CONFIG_SYS_MONITOR_LEN 0x40000/* Reserve 256k */ +#endif #define CONFIG_SYS_MONITOR_BASE (CONFIG_SYS_SDRAM_BASE + \ CONFIG_SYS_SDRAM_SIZE - \ CONFIG_SYS_MONITOR_LEN)
Signature · 1 line
1.6.6.1
PATCH v2 1/1 misc: add gpio based status led driver
In reply to Thomas Choudrivers/misc/gpio_led.c line 25
Quoted 9 lines · On Tuesday, April 20, 2010 20:45:12 Thomas Chou wrote:
drivers/misc/gpio_led.c new file +9
-0+void __led_init (led_id_t mask,int state) +{ +gpio_direction_output (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +} + +void __led_set (led_id_t mask,int state) +{ +gpio_set_value (mask, (state ==STATUS_LED_ON ) ?0 :1 ); +}
are these checks correct ? "on" means a value of "1" with GPIO lines, but here you're setting the value to 0 when the state is "on". so perhaps they should both read:
..., state == STATUS_LED_ON);
drivers/misc/gpio_led.c line 30
Quoted 4 lines
drivers/misc/gpio_led.c new file +4
-0+void __led_toggle (led_id_t mask) +{ +gpio_set_value (mask, !gpio_get_value (mask)); +}
no space before the (mask)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100609/1745ab67/attachment.pgp