diff --git a/board/pcm038/pcm038.c b/board/pcm038/pcm038.c index 392997c34..e34d3c413 100644 --- a/board/pcm038/pcm038.c +++ b/board/pcm038/pcm038.c @@ -27,9 +27,11 @@ #include #include #include +#include #include #include #include +#include static struct device_d cfi_dev = { .name = "cfi_flash", @@ -61,6 +63,21 @@ static struct device_d fec_dev = { .type = DEVICE_TYPE_ETHER, }; +static struct device_d spi_dev = { + .name = "imx_spi", + .id = "spi0", + .map_base = 0x1000e000, +}; + +static struct spi_board_info pcm038_spi_board_info[] = { + { + .name = "mc13783", + .max_speed_hz = 3000000, + .bus_num = 0, + .chip_select = 0, + } +}; + static int pcm038_devices_init(void) { int i; @@ -96,6 +113,9 @@ static int pcm038_devices_init(void) register_device(&cfi_dev); register_device(&sdram_dev); register_device(&fec_dev); + register_device(&spi_dev); + + spi_register_boardinfo(pcm038_spi_board_info, ARRAY_SIZE(pcm038_spi_board_info)); dev_add_partition(&cfi_dev, 0x00000, 0x20000, PARTITION_FIXED, "self"); dev_add_partition(&cfi_dev, 0x20000, 0x20000, PARTITION_FIXED, "env"); diff --git a/drivers/Kconfig b/drivers/Kconfig index eeb582b8f..afb2c4296 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -2,6 +2,7 @@ menu "Drivers " source "drivers/serial/Kconfig" source "drivers/net/Kconfig" +source "drivers/spi/Kconfig" menu "flash drivers " diff --git a/drivers/Makefile b/drivers/Makefile index ecba682f4..586e63760 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,6 +1,7 @@ obj-y += net/ obj-y += serial/ obj-y += nand/ +obj-$(CONFIG_SPI) += spi/ obj-$(CONFIG_DRIVER_CFI_OLD) += cfi_flash.o obj-$(CONFIG_DRIVER_CFI_NEW) += cfi_flash_new.o obj-$(CONFIG_DRIVER_CFI_INTEL) += cfi_flash_intel.o diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig new file mode 100644 index 000000000..1c48ceac7 --- /dev/null +++ b/drivers/spi/Kconfig @@ -0,0 +1,14 @@ +menu "SPI drivers " + +config SPI + bool + default y + +config DRIVER_SPI_IMX + bool "i.MX SPI Master driver" + depends on ARCH_IMX + +config DRIVER_SPI_MC13783 + bool "MC13783 a.k.a. PMIC driver" + +endmenu diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile new file mode 100644 index 000000000..daef09900 --- /dev/null +++ b/drivers/spi/Makefile @@ -0,0 +1,4 @@ +obj-y += spi.o +obj-$(CONFIG_DRIVER_SPI_IMX) += imx_spi.o + +obj-$(CONFIG_DRIVER_SPI_MC13783) += mc13783.o diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c new file mode 100644 index 000000000..641e635e2 --- /dev/null +++ b/drivers/spi/imx_spi.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +static int imx_spi_probe(struct device_d *dev) +{ + struct spi_master *master; + + master = xmalloc(sizeof(struct spi_master)); + + spi_register_master(master); + + return 0; +} + +static struct driver_d imx_spi_driver = { + .name = "imx_spi", + .probe = imx_spi_probe, +}; + +static int imx_spi_init(void) +{ + register_driver(&imx_spi_driver); + return 0; +} + +device_initcall(imx_spi_init); + diff --git a/drivers/spi/mc13783.c b/drivers/spi/mc13783.c new file mode 100644 index 000000000..6c467dfb9 --- /dev/null +++ b/drivers/spi/mc13783.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +static int pmic_probe(struct device_d *dev) +{ + printf("%s\n", __FUNCTION__); + + return 0; +} + +static struct driver_d pmic_driver = { + .name = "mc13783", + .probe = pmic_probe, +}; + +static int pmic_init(void) +{ + printf("%s\n", __FUNCTION__); + register_driver(&pmic_driver); + return 0; +} + +device_initcall(pmic_init); + diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c new file mode 100644 index 000000000..765e34d5e --- /dev/null +++ b/drivers/spi/spi.c @@ -0,0 +1,14 @@ +#include +#include + +int spi_register_boardinfo(struct spi_board_info *info, int num) +{ + printf("%s\n", __FUNCTION__); + return 0; +} + +int spi_register_master(struct spi_master *master) +{ + printf("%s\n", __FUNCTION__); + return 0; +} diff --git a/include/spi/spi.h b/include/spi/spi.h new file mode 100644 index 000000000..2811efce6 --- /dev/null +++ b/include/spi/spi.h @@ -0,0 +1,35 @@ +#ifndef __INCLUDE_SPI_H +#define __INCLUDE_SPI_H + +struct spi_board_info { + char *name; + int max_speed_hz; + int bus_num; + int chip_select; +}; + +struct spi_master { +}; + +struct spi_transfer { + /* it's ok if tx_buf == rx_buf (right?) + * for MicroWire, one buffer must be null + * buffers must work with dma_*map_single() calls, unless + * spi_message.is_dma_mapped reports a pre-existing mapping + */ + const void *tx_buf; + void *rx_buf; + unsigned len; + + unsigned cs_change:1; + u8 bits_per_word; + u16 delay_usecs; + u32 speed_hz; + + struct list_head transfer_list; +}; + +int spi_register_boardinfo(struct spi_board_info *info, int num); +int spi_register_master(struct spi_master *master); + +#endif /* __INCLUDE_SPI_H */