Beaglebone外围电路设计之驱动代码修改
[复制链接]
根据 TI Android ICS 4.0.3 DevKitV3.0.1 AM335x EMV-SK Sources 进行修改。
1 修改使支持beaglebone上的用户指示灯:
修改的源码位置: $HOME/rowboat-android/kernel/arch/arm/mach-omap2/board-am335xevm.c
找到:static struct pinmux_configgpio_led_mux[] = { {"gpmc_ad4.gpio1_4",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_ad5.gpio1_5",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_ad6.gpio1_6",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_ad7.gpio1_7",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {NULL, 0}, };
修改成:static struct pinmux_config gpio_led_mux[] = {
{"gpmc_a5.gpio1_21", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_a6.gpio1_22", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_a7.gpio1_23", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_a8.gpio1_24", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{NULL, 0},
};
找到:
static struct gpio_led gpio_leds[] = {
{
.name = "am335x:EVM_SK:usr0",
.gpio = GPIO_TO_PIN(1, 4), /* D1 */
},
{
.name = "am335x:EVM_SK:usr1",
.gpio = GPIO_TO_PIN(1, 5), /* D2 */
},
{
.name = "am335x:EVM_SK:mmc0",
.gpio = GPIO_TO_PIN(1, 7), /* D3 */
.default_trigger = "mmc0",
},
{
.name = "am335x:EVM_SK:heartbeat",
.gpio = GPIO_TO_PIN(1, 6), /* D4 */
.default_trigger = "heartbeat",
},
};
修改成:
static struct gpio_led gpio_leds[] = {
{
.name = "am335x:EVM_SK:usr0",
.gpio = GPIO_TO_PIN(1,21), /* D1 */
},
{
.name = "am335x:EVM_SK:usr1",
.gpio = GPIO_TO_PIN(1, 22), /* D2 */
},
{
.name = "am335x:EVM_SK:mmc0",
.gpio = GPIO_TO_PIN(1, 23), /* D3 */
.default_trigger = "mmc0",
},
{
.name = "am335x:EVM_SK:heartbeat",
.gpio = GPIO_TO_PIN(1, 24), /* D4 */
.default_trigger = "heartbeat",
},
};
2 修改按键驱动
修改的源码位置: $HOME/rowboat-android/kernel/arch/arm/mach-omap2/board-am335xevm.c
如修改LEDS一样修改两个地方:
/* pinmux for gpio based key */
static struct pinmux_config gpio_keys_pin_mux[] = {
{"gpmc_wait0.gpio0_30", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_oen_ren.gpio2_3", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_advn_ale.gpio2_2", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_ben0_cle.gpio2_5", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{NULL, 0},
};
/* Configure GPIOs for GPIO Keys */
static struct gpio_keys_button am335x_evm_gpio_buttons[] = {
{
.code = BTN_0,
.gpio = GPIO_TO_PIN(2, 3),
.desc = "SW1",
},
{
.code = BTN_1,
.gpio = GPIO_TO_PIN(2, 2),
.desc = "SW2",
},
{
.code = BTN_2,
.gpio = GPIO_TO_PIN(0, 30),
.desc = "SW3",
.wakeup = 1,
},
{
.code = BTN_3,
.gpio = GPIO_TO_PIN(2, 5),
.desc = "SW4",
},
};
注:修改成扩展板对应的按键管脚,驱动是读取高电平有效,如果是需要低电平有效,就在结构体中加入 :active_low=1;
驱动源码位于: $HOME/rowboat-android/kernel/arch/driver/input/gpio_keys.c
3 修改触摸屏驱动
修改的源码位置: $HOME/rowboat-android/kernel/arch/arm/mach-omap2/board-am335xevm.c
/* TSc controller */
static struct tsc_data am335x_touchscreen_data = {
.wires = 4,
.x_max = 0x0fff,
.y_max = 0x0fff,
.x_plate_resistance = 200,
};
注:.x_plate_resistance根据具体触摸屏修改。
修改的源码位于: $HOME/rowboat-android/kernel/arch/driver/input/touchscreen/ti_tscadc.c,其中的:
#ifdef CONFIG_MACH_AM335XEVM
/* Define Touch Screen Boundary Limits */
#define AM335X_TS_XMIN 0xA5
#define AM335X_TS_XMAX 0xFB0
#define AM335X_TS_YMIN 0xDC
#define AM335X_TS_YMAX 0xF43
#endif
根据触摸屏的具体情况修改。可根据校准生成文件修改。
4 7寸液晶屏驱动修改:
修改的源码位置: $HOME/rowboat-android/kernel/arch/arm/mach-omap2/board-am335xevm.c
1
static struct lcd_ctrl_config bone_lcd_cape_cfg = {
&bone_lcd_cape_disp_panel,
.ac_bias = 255,
.ac_bias_intrpt = 0,
.dma_burst_sz = 16,
.bpp = 16,
.fdd = 0x80,
.tft_alt_mode = 0,
.stn_565_mode = 0,
.mono_8bit_mode = 0,
.invert_line_clock = 1,
.invert_frm_clock = 1,
.sync_edge = 0,
.sync_ctrl = 1,
.raster_order = 0,
};
注:实际需要参数根据液晶屏修改
2 增加一个da8xx_lcdc_platform_data:
struct da8xx_lcdc_platform_data my_lcd_pdata = {
.manu_name = "XXX",
.controller_data = &bone_lcd_cape_cfg,
.type = "YYY",
};
注:XXX,YYY想写什么就写什么,关键是要与接下来的对应起来
3 修改static void bone_lcdc_init(int evm_id, int profile) 函数:
if (am33xx_register_lcdc(&TFC_S9700RTWV35TR_01B_bone_lcd_cape_pdata))
修改成:
if (am33xx_register_lcdc(&my_lcd_pdat))
接下来:
修改的源码位于: $HOME/rowboat-android/kernel/arch/driver/video/Da8xx-fb.c
在结构体
static struct da8xx_panel known_lcd_panels[] = 中添加成员:
[5] = {
.name = "YYY",
.width = 800,
.height = 480,
.hfp = 40,
.hbp = 38,
.hsw = 48,
.vfp = 16,
.vbp =28,
.vsw = 3,
.pxl_clk = 30000000,
.invert_pxl_clk = 0,
},
注:YYY与da8xx_lcdc_platform_data中的YYY要一致。
完成上述修改后,需要在
$HOME/rowboat-android/kernel/arch/arm/mach-omap2/board-am335xevm.c 中修改:
static struct evm_dev_cfg beaglebone_dev_cfg[] = {
{tps65217_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{mii1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{usb0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{i2c2_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{gpio_led_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{gpio_keys_init, DEV_ON_BASEBOARD,PROFILE_NONE},
{bone_lcdc_init,DEV_ON_BASEBOARD, PROFILE_NONE},
{lcd_cape_tsc_init,DEV_ON_BASEBOARD, PROFILE_NONE},
{NULL, 0, 0},
};
修改后 重新制作SD卡启动效果:
|