* [PATCH 0/4] at91sam9x5ek: add spi and mci support @ 2012-11-01 19:30 Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 1/4] at91sam9x5: add spi support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:30 UTC (permalink / raw) To: barebox HI, with this +1 patch serie the support of the at91sam9x5ek is mostly complete This will add spi and mci0 support as spi0 and mci0 conflict We are still missing framebuffer, usb host and device and hardware i2c support but this wil be added later This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries The following changes since commit 04ffb7b107af50bd64d803b72e5fc315180381a2: m25p80: sync flash support with the kernel (2012-11-01 12:15:26 +0800) are available in the git repository at: git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi for you to fetch changes up to 2c12218e89c0318dc9bed4f7f397b68903b4203e: at91sam9x5ek: add mci support (2012-11-01 12:15:41 +0800) ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (4): at91sam9x5: add spi support at91sam9x5ek: add spi support at91sam9x5: add mci support at91sam9x5ek: add mci support arch/arm/boards/at91sam9x5ek/init.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/configs/at91sam9x5ek_defconfig | 10 +++++++--- arch/arm/mach-at91/at91sam9x5.c | 4 ++++ arch/arm/mach-at91/at91sam9x5_devices.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+), 3 deletions(-) Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] at91sam9x5: add spi support 2012-11-01 19:30 [PATCH 0/4] at91sam9x5ek: add spi and mci support Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 ` Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 2/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/mach-at91/at91sam9x5.c | 2 + arch/arm/mach-at91/at91sam9x5_devices.c | 62 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index c256989..a9065ff 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -205,6 +205,8 @@ static struct clk_lookup periph_clocks_lookups[] = { CLKDEV_CON_DEV_ID("macb_clk", "macb0", &macb0_clk), CLKDEV_CON_DEV_ID("macb_clk", "macb1", &macb1_clk), CLKDEV_CON_ID("ohci_clk", &uhphs_clk), + CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk), + CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk), }; static struct clk_lookup usart_clocks_lookups[] = { diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c index 5a24325..710ded7 100644 --- a/arch/arm/mach-at91/at91sam9x5_devices.c +++ b/arch/arm/mach-at91/at91sam9x5_devices.c @@ -228,6 +228,68 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de #endif /* -------------------------------------------------------------------- + * SPI + * -------------------------------------------------------------------- */ + +#if defined(CONFIG_DRIVER_SPI_ATMEL) +static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 }; + +static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 }; + +static struct at91_spi_platform_data spi_pdata[] = { + [0] = { + .chipselect = spi0_standard_cs, + .num_chipselect = ARRAY_SIZE(spi0_standard_cs), + }, + [1] = { + .chipselect = spi1_standard_cs, + .num_chipselect = ARRAY_SIZE(spi1_standard_cs), + }, +}; + +void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) +{ + int i; + int cs_pin; + resource_size_t start = ~0; + + BUG_ON(spi_id > 1); + + if (!pdata) + pdata = &spi_pdata[spi_id]; + + for (i = 0; i < pdata->num_chipselect; i++) { + cs_pin = pdata->chipselect[i]; + + /* enable chip-select pin */ + if (cs_pin > 0) + at91_set_gpio_output(cs_pin, 1); + } + + /* Configure SPI bus(es) */ + switch (spi_id) { + case 0: + start = AT91SAM9X5_BASE_SPI0; + at91_set_A_periph(AT91_PIN_PA11, 0); /* SPI0_MISO */ + at91_set_A_periph(AT91_PIN_PA12, 0); /* SPI0_MOSI */ + at91_set_A_periph(AT91_PIN_PA13, 0); /* SPI0_SPCK */ + break; + case 1: + start = AT91SAM9X5_BASE_SPI1; + at91_set_B_periph(AT91_PIN_PA21, 0); /* SPI1_MISO */ + at91_set_B_periph(AT91_PIN_PA22, 0); /* SPI1_MOSI */ + at91_set_B_periph(AT91_PIN_PA23, 0); /* SPI1_SPCK */ + break; + } + + add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K, + IORESOURCE_MEM, pdata); +} +#else +void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {} +#endif + +/* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] at91sam9x5ek: add spi support 2012-11-01 19:36 ` [PATCH 1/4] at91sam9x5: add spi support Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 ` Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 3/4] at91sam9x5: add mci support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 4/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD 2 siblings, 0 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 UTC (permalink / raw) To: barebox on all the cpu module we have a at25 except on the cogent where we have a at45 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/at91sam9x5ek/init.c | 31 +++++++++++++++++++++++++++++++ arch/arm/configs/at91sam9x5ek_defconfig | 5 ++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c index 48eebac..8f9fc0f 100644 --- a/arch/arm/boards/at91sam9x5ek/init.c +++ b/arch/arm/boards/at91sam9x5ek/init.c @@ -41,6 +41,7 @@ #include <readkey.h> #include <linux/w1-gpio.h> #include <w1_mac_address.h> +#include <spi/spi.h> #include "hw_version.h" @@ -125,6 +126,35 @@ static void ek_add_device_i2c(void) at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices)); } +static const struct spi_board_info ek_cm_cogent_spi_devices[] = { + { + .name = "mtd_dataflash", + .chip_select = 0, + .max_speed_hz = 15 * 1000 * 1000, + .bus_num = 0, + } +}; + +static const struct spi_board_info ek_spi_devices[] = { + { + .name = "m25p80", + .chip_select = 0, + .max_speed_hz = 30 * 1000 * 1000, + .bus_num = 0, + } +}; + +static void ek_add_device_spi(void) +{ + if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT)) + spi_register_board_info(ek_cm_cogent_spi_devices, + ARRAY_SIZE(ek_cm_cogent_spi_devices)); + else + spi_register_board_info(ek_spi_devices, + ARRAY_SIZE(ek_spi_devices)); + at91_add_device_spi(0, NULL); +} + /* * USB Host port */ @@ -181,6 +211,7 @@ static int at91sam9x5ek_devices_init(void) ek_add_device_w1(); ek_add_device_nand(); ek_add_device_eth(); + ek_add_device_spi(); at91_add_device_usbh_ohci(&ek_usbh_data); ek_add_led(); ek_add_device_i2c(); diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig index c71fe0d..5611b95 100644 --- a/arch/arm/configs/at91sam9x5ek_defconfig +++ b/arch/arm/configs/at91sam9x5ek_defconfig @@ -52,10 +52,13 @@ CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_NET_NETCONSOLE=y CONFIG_DRIVER_NET_MACB=y -# CONFIG_SPI is not set +CONFIG_DRIVER_SPI_ATMEL=y +CONFIG_MTD_M25P80=y CONFIG_I2C=y CONFIG_I2C_GPIO=y CONFIG_MTD=y +# CONFIG_MTD_OOB_DEVICE is not set +CONFIG_MTD_DATAFLASH=y CONFIG_NAND=y # CONFIG_NAND_ECC_HW is not set # CONFIG_NAND_ECC_HW_SYNDROME is not set -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] at91sam9x5: add mci support 2012-11-01 19:36 ` [PATCH 1/4] at91sam9x5: add spi support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 2/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 ` Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 4/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD 2 siblings, 0 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/mach-at91/at91sam9x5.c | 2 + arch/arm/mach-at91/at91sam9x5_devices.c | 62 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index a9065ff..7c7d997 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -207,6 +207,8 @@ static struct clk_lookup periph_clocks_lookups[] = { CLKDEV_CON_ID("ohci_clk", &uhphs_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk), + CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci0", &mmc0_clk), + CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk), }; static struct clk_lookup usart_clocks_lookups[] = { diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c index 710ded7..14fcb1e 100644 --- a/arch/arm/mach-at91/at91sam9x5_devices.c +++ b/arch/arm/mach-at91/at91sam9x5_devices.c @@ -123,6 +123,68 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data) void at91_add_device_eth(int id, struct at91_ether_platform_data *data) {} #endif +#if defined(CONFIG_MCI_ATMEL) +/* Consider only one slot : slot 0 */ +void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) +{ + resource_size_t start = ~0; + + if (!data) + return; + + /* Must have at least one usable slot */ + if (!data->bus_width) + return; + + /* input/irq */ + if (data->detect_pin) { + at91_set_gpio_input(data->detect_pin, 1); + at91_set_deglitch(data->detect_pin, 1); + } + if (data->wp_pin) + at91_set_gpio_input(data->wp_pin, 1); + + if (mmc_id == 0) { /* MCI0 */ + start = AT91SAM9X5_BASE_MCI0; + + /* CLK */ + at91_set_A_periph(AT91_PIN_PA17, 0); + + /* CMD */ + at91_set_A_periph(AT91_PIN_PA16, 1); + + /* DAT0, maybe DAT1..DAT3 */ + at91_set_A_periph(AT91_PIN_PA15, 1); + if (data->bus_width == 4) { + at91_set_A_periph(AT91_PIN_PA18, 1); + at91_set_A_periph(AT91_PIN_PA19, 1); + at91_set_A_periph(AT91_PIN_PA20, 1); + } + } else { /* MCI1 */ + start = AT91SAM9X5_BASE_MCI1; + + /* CLK */ + at91_set_B_periph(AT91_PIN_PA13, 0); + + /* CMD */ + at91_set_B_periph(AT91_PIN_PA12, 1); + + /* DAT0, maybe DAT1..DAT3 */ + at91_set_B_periph(AT91_PIN_PA11, 1); + if (data->bus_width == 4) { + at91_set_B_periph(AT91_PIN_PA2, 1); + at91_set_B_periph(AT91_PIN_PA3, 1); + at91_set_B_periph(AT91_PIN_PA4, 1); + } + } + + add_generic_device("atmel_mci", mmc_id, NULL, start, SZ_16K, + IORESOURCE_MEM, data); +} +#else +void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {} +#endif + /* -------------------------------------------------------------------- * NAND / SmartMedia * -------------------------------------------------------------------- */ -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] at91sam9x5ek: add mci support 2012-11-01 19:36 ` [PATCH 1/4] at91sam9x5: add spi support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 2/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 3/4] at91sam9x5: add mci support Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 ` Jean-Christophe PLAGNIOL-VILLARD 2 siblings, 0 replies; 5+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 19:36 UTC (permalink / raw) To: barebox only add mci0 (microSD slot) as mci1 conflict with spi0 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/at91sam9x5ek/init.c | 20 ++++++++++++++++++++ arch/arm/configs/at91sam9x5ek_defconfig | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c index 8f9fc0f..681be32 100644 --- a/arch/arm/boards/at91sam9x5ek/init.c +++ b/arch/arm/boards/at91sam9x5ek/init.c @@ -115,6 +115,25 @@ static void ek_add_device_eth(void) at91_add_device_eth(0, &macb_pdata); } +/* + * MCI (SD/MMC) + */ +/* mci0 detect_pin is revision dependent */ +static struct atmel_mci_platform_data mci0_data = { + .bus_width = 4, + .detect_pin = AT91_PIN_PD15, + .wp_pin = 0, +}; + +static void ek_add_device_mci(void) +{ + if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT)) + mci0_data.detect_pin = 0; + + /* MMC0 */ + at91_add_device_mci(0, &mci0_data); +} + static struct i2c_board_info i2c_devices[] = { { I2C_BOARD_INFO("qt1070", 0x1b), @@ -212,6 +231,7 @@ static int at91sam9x5ek_devices_init(void) ek_add_device_nand(); ek_add_device_eth(); ek_add_device_spi(); + ek_add_device_mci(); at91_add_device_usbh_ohci(&ek_usbh_data); ek_add_led(); ek_add_device_i2c(); diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig index 5611b95..d097683 100644 --- a/arch/arm/configs/at91sam9x5ek_defconfig +++ b/arch/arm/configs/at91sam9x5ek_defconfig @@ -65,8 +65,9 @@ CONFIG_NAND=y # CONFIG_NAND_ECC_HW_NONE is not set CONFIG_NAND_ATMEL=y CONFIG_UBI=y -CONFIG_DISK=y -CONFIG_DISK_WRITE=y +CONFIG_MCI=y +CONFIG_MCI_STARTUP=y +CONFIG_MCI_ATMEL=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_LED_TRIGGERS=y -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-01 19:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-11-01 19:30 [PATCH 0/4] at91sam9x5ek: add spi and mci support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 1/4] at91sam9x5: add spi support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 2/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 3/4] at91sam9x5: add mci support Jean-Christophe PLAGNIOL-VILLARD 2012-11-01 19:36 ` [PATCH 4/4] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox