Skip to contentSkip to conversation

atmel nand/spi/udc: request gpio

PATCH Applied Jean-Christophe PLAGNIOL-VILLARD 2 participants 5 messages Dec 28, 2012 – Jan 2, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover atmel nand/spi/udc: request gpio

Hi,

request and configure gpio via gpiolib for some of the Atmel drivers:

- Nand
- SPI
- at91 udc

The following changes since commit 95bc1eacae260a56c233179bc0fbd6245f2c68ed:

qil-a9260-64: ser2net config (2012-12-28 00:33:06 +0800)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git delivery/at91_gpio

for you to fetch changes up to 52f0cda71c7e10a8bdf4a0976c7f7dee3a4f9678:

spi: atmel: request cs pin via gpiolib (2012-12-29 00:29:39 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
mtd: atmel_nand: request and configure pio via gpiolib
usb: at91_udc: request and configure vbus pin via gpiolib
spi: atmel: request cs pin via gpiolib

 drivers/mtd/nand/atmel_nand.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/spi/atmel_spi.c       |    8 ++++++++
 drivers/usb/gadget/at91_udc.c |    7 +++++++
 3 files changed, 66 insertions(+), 2 deletions(-)

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/3 mtd: atmel_nand: request and configure pio via gpiolib

---
 drivers/mtd/nand/atmel_nand.c |   53 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/mtd/nand/atmel_nand.c +51 -2
index 7e0de51..2a57dbb 100644
@@ -1114,8 +1114,42 @@ static int __init atmel_nand_probe(struct device_d *dev)
 	nand_chip->IO_ADDR_W = host->io_base;
 	nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
 
-	if (gpio_is_valid(host->board->rdy_pin))
+	if (gpio_is_valid(host->board->rdy_pin)) {
+		res = gpio_request(host->board->rdy_pin, "nand_rdy");
+		if (res < 0) {
+			dev_err(dev, "can't request rdy gpio %d\n",
+				host->board->rdy_pin);
+			goto err_no_card;
+		}
+
+		res = gpio_direction_input(host->board->rdy_pin);
+		if (res < 0) {
+			dev_err(dev,
+				"can't request input direction rdy gpio %d\n",
+				host->board->rdy_pin);
+			goto err_no_card;
+		}
+
 		nand_chip->dev_ready = atmel_nand_device_ready;
+	}
+
+	if (gpio_is_valid(host->board->enable_pin)) {
+		res = gpio_request(host->board->enable_pin, "nand_enable");
+		if (res < 0) {
+			dev_err(dev,
+				"can't request enable gpio %d\n",
+				host->board->enable_pin);
+			goto err_no_card;
+		}
+
+		res = gpio_direction_output(host->board->enable_pin, 1);
+		if (res < 0) {
+			dev_err(dev,
+				"can't request output direction enable gpio %d\n",
+				host->board->enable_pin);
+			goto err_no_card;
+		}
+	}
 
 	nand_chip->ecc.mode = NAND_ECC_SOFT;
 
@@ -1138,9 +1172,24 @@ static int __init atmel_nand_probe(struct device_d *dev)
 	atmel_nand_enable(host);
 
 	if (gpio_is_valid(host->board->det_pin)) {
+		res = gpio_request(host->board->det_pin, "nand_det");
+		if (res < 0) {
+			dev_err(dev, "can't request det gpio %d\n",
+				host->board->det_pin);
+			goto err_no_card;
+		}
+
+		res = gpio_direction_input(host->board->det_pin);
+		if (res < 0) {
+			dev_err(dev,
+				"can't request input direction det gpio %d\n",
+				host->board->det_pin);
+			goto err_no_card;
+		}
+
 		if (gpio_get_value(host->board->det_pin)) {
 			printk("No SmartMedia card inserted.\n");
-			res = ENXIO;
+			res = -ENXIO;
 			goto err_no_card;
 		}
 	}
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/3 usb: at91_udc: request and configure vbus pin via gpiolib

---
 drivers/usb/gadget/at91_udc.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/gadget/at91_udc.c +7 -0
index 8a678f9..3899db2 100644
@@ -1497,6 +1497,13 @@ static int __init at91udc_probe(struct device_d *dev)
 	clk_disable(udc->iclk);
 
 	if (gpio_is_valid(udc->board.vbus_pin)) {
+		retval = gpio_request(udc->board.vbus_pin, "udc_vbus");
+		if (retval < 0) {
+			dev_err(dev, "request vbus pin failed\n");
+			goto fail0a;
+		}
+		gpio_direction_input(udc->board.vbus_pin);
+
 		/*
 		 * Get the initial state of VBUS - we cannot expect
 		 * a pending interrupt.
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 spi: atmel: request cs pin via gpiolib

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 drivers/spi/atmel_spi.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/spi/atmel_spi.c +8 -0
index 793933e..08cb416 100644
@@ -371,6 +371,7 @@ err:
 static int atmel_spi_probe(struct device_d *dev)
 {
 	int ret = 0;
+	int i;
 	struct spi_master *master;
 	struct atmel_spi *as;
 	struct at91_spi_platform_data *pdata = dev->platform_data;
@@ -399,6 +400,12 @@ static int atmel_spi_probe(struct device_d *dev)
 	as->cs_pins = pdata->chipselect;
 	as->regs = dev_request_mem_region(dev, 0);
 
+	for (i = 0; i <= master->num_chipselect; i++) {
+		ret = gpio_request(as->cs_pins[i], dev_name(dev));
+		if (ret)
+			goto out_gpio;
+	}
+
 	/* Initialize the hardware */
 	clk_enable(as->clk);
 	spi_writel(as, CR, SPI_BIT(SWRST));
@@ -418,6 +425,7 @@ static int atmel_spi_probe(struct device_d *dev)
 out_reset_hw:
 	spi_writel(as, CR, SPI_BIT(SWRST));
 	spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+out_gpio:
 	clk_disable(as->clk);
 	clk_put(as->clk);
 out_free:
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#4 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD

Hi,

request and configure gpio via gpiolib for some of the Atmel drivers:

- Nand
- SPI
- at91 udc

Quoted 8 lines

The following changes since commit 95bc1eacae260a56c233179bc0fbd6245f2c68ed:

qil-a9260-64: ser2net config (2012-12-28 00:33:06 +0800)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git delivery/at91_gpio

Applied, thanks

Sascha

Quoted 23 lines

for you to fetch changes up to 52f0cda71c7e10a8bdf4a0976c7f7dee3a4f9678:

spi: atmel: request cs pin via gpiolib (2012-12-29 00:29:39 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
mtd: atmel_nand: request and configure pio via gpiolib
usb: at91_udc: request and configure vbus pin via gpiolib
spi: atmel: request cs pin via gpiolib

 drivers/mtd/nand/atmel_nand.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/spi/atmel_spi.c       |    8 ++++++++
 drivers/usb/gadget/at91_udc.c |    7 +++++++
 3 files changed, 66 insertions(+), 2 deletions(-)

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox