AM335X的SPI1只有2个片选,但我要接3个SPI从设备,使用spi1_cs0和spi1_cs1设备可以正常工作,我现在想使用GPMC_CSn1作为一个片选使用再接一个设备,下面是我修改board_am335xevm.c
SPI引脚的初始化(最后一行加入了gpmc_csn1管脚):
static struct pinmux_config spi1_pin_mux[] = {
{"mcasp0_aclkx.spi1_sclk", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
| AM33XX_INPUT_EN},
{"mcasp0_fsx.spi1_d0", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
| AM33XX_PULL_UP | AM33XX_INPUT_EN},
{"mcasp0_axr0.spi1_d1", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
| AM33XX_INPUT_EN},
{"rmii1_refclk.spi1_cs0", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL
| AM33XX_PULL_UP | AM33XX_INPUT_EN},
{"xdma_event_intr0.spi1_cs1", OMAP_MUX_MODE4 | AM33XX_PULL_ENBL
| AM33XX_PULL_UP | AM33XX_INPUT_EN},
{"gpmc_csn1.gpmc_csn1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL
| AM33XX_PULL_UP | AM33XX_INPUT_EN},
{NULL, 0},
};
SPI的初始化( .chip_select = 0和 .chip_select = 1 ,这里的片选0和1是怎么和管脚rmii1_refclk.spi1_cs0和xdma_event_intr0.spi1_cs1建立联系的?)
static struct spi_board_info spi_board_info[] = {
{
.modalias = "mcp2515",
// or "mcp2515" depending on your controller
.platform_data = &mcp251x_info,
.irq = 224,
.mode =SPI_MODE_0,
.max_speed_hz = 10000000,
.bus_num = 2,
.chip_select = 0,
},
};
static struct spi_board_info spi_board_info_1[] = {
{
.modalias = "mcp2515",
// or "mcp2515" depending on your controller
.platform_data = &mcp251x_info,
.irq = 223,
.mode =SPI_MODE_0,
.max_speed_hz = 10000000,
.bus_num = 2,
.chip_select = 1,
},
};
static struct spi_board_info spi_board_info_2[] = {
{
.modalias = "mcp2515",
// or "mcp2515" depending on your controller
.platform_data = &mcp251x_info,
.irq = 223,
.mode =SPI_MODE_0,
.max_speed_hz = 10000000,
.bus_num = 2,
.chip_select = 2,
},
注册SPI设备:
}static void spi1_init(int evm_id, int profile)
{
setup_pin_mux(spi1_pin_mux);
spi_register_board_info(spi_board_info,
ARRAY_SIZE(spi_board_info));
spi_register_board_info(spi_board_info_1,
ARRAY_SIZE(spi_board_info_1));
spi_register_board_info(spi_board_info_2,
ARRAY_SIZE(spi_board_info_2));
return;
};
但内核启动后只打印了SPI2.0和SPI2.1,没有SPI2.2
请问我该怎么样扩展SPI的片选? |