9
0
Fork 0

beginning of SPI support

This commit is contained in:
Sascha Hauer 2008-03-11 22:13:06 +01:00
parent 5864a49007
commit 906eea397a
9 changed files with 146 additions and 0 deletions

View File

@ -27,9 +27,11 @@
#include <fec.h>
#include <asm/arch/gpio.h>
#include <asm/armlinux.h>
#include <asm/mach-types.h>
#include <partition.h>
#include <fs.h>
#include <fcntl.h>
#include <spi/spi.h>
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");

View File

@ -2,6 +2,7 @@ menu "Drivers "
source "drivers/serial/Kconfig"
source "drivers/net/Kconfig"
source "drivers/spi/Kconfig"
menu "flash drivers "

View File

@ -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

14
drivers/spi/Kconfig Normal file
View File

@ -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

4
drivers/spi/Makefile Normal file
View File

@ -0,0 +1,4 @@
obj-y += spi.o
obj-$(CONFIG_DRIVER_SPI_IMX) += imx_spi.o
obj-$(CONFIG_DRIVER_SPI_MC13783) += mc13783.o

30
drivers/spi/imx_spi.c Normal file
View File

@ -0,0 +1,30 @@
#include <common.h>
#include <init.h>
#include <driver.h>
#include <spi/spi.h>
#include <xfuncs.h>
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);

27
drivers/spi/mc13783.c Normal file
View File

@ -0,0 +1,27 @@
#include <common.h>
#include <init.h>
#include <driver.h>
#include <spi/spi.h>
#include <xfuncs.h>
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);

14
drivers/spi/spi.c Normal file
View File

@ -0,0 +1,14 @@
#include <common.h>
#include <spi/spi.h>
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;
}

35
include/spi/spi.h Normal file
View File

@ -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 */