硬件平台是基于BeagleBone Black设计的扩展板:
https://bbs.eeworld.com.cn/thread-440975-1-1.html在这之前所有的外围驱动都是直接编辑板级文件,将代码直接编译进内核的!
更新到内核linux-rt-4.4.19后,可直接利用设备树进行设备的开发,关于设备树的介绍,大家可自行检索,我不再赘述。
具体步骤:
使能rt系统的LCD。
先找到要修改的文件:
/opt/ti-processor-sdk-linux-rt-am335x-evm-03.01.00.06/board-support/linux-rt-4.4.19+gitAUTOINC+f572d285f0-gf572d285f0/arch/arm/boot/dts/am335x-boneblack.dts
看一看其内容:
发现,其显示部分使能的时HDMI,所以参考am335x-evm.dts,现将LCD功能加进去!
去掉HDMI和其sound(i2c0)的功能,使用板载的LCD和声卡!
首先加LCD显示和背光控制功能,保留bbb板的ldo,rtc等功能,
执行:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tisdk_am335x-evm-rt_defconfig
(tisdk_am335x-evm-rt_defconfig存在于目录:/opt/ti-processor-sdk-linux-rt-am335x-evm-03.01.00.06/board-support/linux-rt-4.4.19+gitAUTOINC+f572d285f0-gf572d285f0/arch/arm/configs)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
(屡次报错:In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: 没有那个文件或目录
#include CURSES_LOC
^
compilation terminated.
make[1]: *** [scripts/kconfig/mconf.o] 错误 1
make: *** [menuconfig] 错误 2
原因:提示了scripts/kconfig/lxdialog/dialog.h:38:20,一看就是没有相关依赖库,于是百度了一下,大家都说是缺少libcurses5-dev这个东西
解决方案:
)sudo apt-get install libncurses5-dev
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x-boneblack.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
sudo cp arch/arm/boot/zImage /media/anananjjj/rootfs/boot
sudo cp arch/arm/boot/dts/am335x-boneblack.dtb /media/anananjjj/rootfs/boot
sudo make ARCH=arm INSTALL_MOD_PATH=/media/anananjjj/rootfs modules_install
执行完毕后,LCD功能测试成功!!
具体调试:
修改:
panel {
compatible = "ti,tilcdc,panel";
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&lcd_pins_s0>;
panel-info {
ac-bias = <255>;
ac-bias-intrpt = <0>;
dma-burst-sz = <16>;
bpp = <32>;
fdd = <0x80>;
sync-edge = <0>;
sync-ctrl = <1>;
raster-order = <0>;
fifo-th = <0>;
};
display-timings {
800x480p62 {
clock-frequency = <30000000>;
hactive = <800>;
vactive = <480>;
hfront-porch = <39>;
hback-porch = <39>;
hsync-len = <47>;
vback-porch = <29>;
vfront-porch = <13>;
vsync-len = <2>;
hsync-active = <1>;
vsync-active = <1>;
};
};
};
增加引脚设置:
lcd_pins_s0: lcd_pins_s0 {
pinctrl-single,pins = <
0x20 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad8.lcd_data23 */
0x24 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad9.lcd_data22 */
0x28 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad10.lcd_data21 */
0x2c (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad11.lcd_data20 */
0x30 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad12.lcd_data19 */
0x34 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad13.lcd_data18 */
0x38 (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad14.lcd_data17 */
0x3c (PIN_OUTPUT | MUX_MODE1) /* gpmc_ad15.lcd_data16 */
0xa0 (PIN_OUTPUT | MUX_MODE0) /* lcd_data0.lcd_data0 */
0xa4 (PIN_OUTPUT | MUX_MODE0) /* lcd_data1.lcd_data1 */
0xa8 (PIN_OUTPUT | MUX_MODE0) /* lcd_data2.lcd_data2 */
0xac (PIN_OUTPUT | MUX_MODE0) /* lcd_data3.lcd_data3 */
0xb0 (PIN_OUTPUT | MUX_MODE0) /* lcd_data4.lcd_data4 */
0xb4 (PIN_OUTPUT | MUX_MODE0) /* lcd_data5.lcd_data5 */
0xb8 (PIN_OUTPUT | MUX_MODE0) /* lcd_data6.lcd_data6 */
0xbc (PIN_OUTPUT | MUX_MODE0) /* lcd_data7.lcd_data7 */
0xc0 (PIN_OUTPUT | MUX_MODE0) /* lcd_data8.lcd_data8 */
0xc4 (PIN_OUTPUT | MUX_MODE0) /* lcd_data9.lcd_data9 */
0xc8 (PIN_OUTPUT | MUX_MODE0) /* lcd_data10.lcd_data10 */
0xcc (PIN_OUTPUT | MUX_MODE0) /* lcd_data11.lcd_data11 */
0xd0 (PIN_OUTPUT | MUX_MODE0) /* lcd_data12.lcd_data12 */
0xd4 (PIN_OUTPUT | MUX_MODE0) /* lcd_data13.lcd_data13 */
0xd8 (PIN_OUTPUT | MUX_MODE0) /* lcd_data14.lcd_data14 */
0xdc (PIN_OUTPUT | MUX_MODE0) /* lcd_data15.lcd_data15 */
0xe0 (PIN_OUTPUT | MUX_MODE0) /* lcd_vsync.lcd_vsync */
0xe4 (PIN_OUTPUT | MUX_MODE0) /* lcd_hsync.lcd_hsync */
0xe8 (PIN_OUTPUT | MUX_MODE0) /* lcd_pclk.lcd_pclk */
0xec (PIN_OUTPUT | MUX_MODE0) /* lcd_ac_bias_en.lcd_ac_bias_en */
>;
};
增加:
&lcdc {
status = "okay";
};
添加触摸驱动edt_ft5x06!
接下来修改设备树文件!
增加i2C2
//cap touch pins set
i2c2_pins: pinmux_i2c2_pins {
pinctrl-single,pins = <
0x178 (PIN_INPUT_PULLUP | MUX_MODE3) /* uart1_ctsn.i2c2_sda */
0x17c (PIN_INPUT_PULLUP | MUX_MODE3) /* uart1_rtsn.i2c2_scl */
>;
};
edt_ft5x06_ts_pins: edt_ft5x06_ts_pins {
pinctrl-single,pins = <
0x1a0 (PIN_INPUT | MUX_MODE7) /* mcasp0_aclkr.gpio3_18 */
>;
};
&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins>;
status = "okay";
clock-frequency = <100000>;
//i2c device address:0x38
polytouch: edt-ft5x06@38 {
status = "okay";
compatible = "edt,edt-ft5x06";
pinctrl-names = "default";
pinctrl-0 = <&edt_ft5x06_ts_pins>;
reg = <0x38>;
interrupt-parent = <&gpio3>;
interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
// reset-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
// wake-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
touchscreen-size-x = <800>;
touchscreen-size-y = <480>;
//touchscreen-inverted-x;
//touchscreen-swapped-x-y;
};
};
增加codec tlv320aic3106 驱动!
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "AM335x-EVM";
simple-audio-card,widgets =
"Headphone", "Headphone Jack",
"Line", "Line In";
simple-audio-card,routing =
"Headphone Jack", "HPLOUT",
"Headphone Jack", "HPROUT",
"LINE1L", "Line In",
"LINE1R", "Line In";
simple-audio-card,format = "dsp_b";
simple-audio-card,bitclock-master = <&sound_master>;
simple-audio-card,frame-master = <&sound_master>;
simple-audio-card,bitclock-inversion;
simple-audio-card,cpu {
sound-dai = <&mcasp0>;
};
sound_master: simple-audio-card,codec {
sound-dai = <&tlv320aic3106>;
system-clock-frequency = <12000000>;
};
};
mcasp0_pins: mcasp0_pins {
pinctrl-single,pins = <
0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx, INPUT | MODE0 */
0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx, INPUT | MODE0 */
0x19c (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2, OUTPUT | MODE2 */
0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE2) /* mcasp0_ahclkx.mcasp0_axr3, INPUT | MODE2 */
>;
};
mcasp0_pins_sleep: mcasp0_pins_sleep {
pinctrl-single,pins = <
0x190 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x194 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x19c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};
&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins>;
status = "okay";
clock-frequency = <100000>;
//i2c device address:0x38
polytouch: edt-ft5x06@38 {
status = "okay";
compatible = "edt,edt-ft5x06";
pinctrl-names = "default";
pinctrl-0 = <&edt_ft5x06_ts_pins>;
reg = <0x38>;
interrupt-parent = <&gpio3>;
interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
// reset-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
// wake-gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
touchscreen-size-x = <800>;
touchscreen-size-y = <480>;
//touchscreen-inverted-x;
//touchscreen-swapped-x-y;
};
tlv320aic3106: tlv320aic3106@1b {
#sound-dai-cells = <0>;
compatible = "ti,tlv320aic3106";
reg = <0x1b>;
status = "okay";
/* Regulators */
AVDD-supply = <&ldo3_reg>;
IOVDD-supply = <&ldo3_reg>;
DRVDD-supply = <&ldo3_reg>;
DVDD-supply = <&dcdc1_reg>;
};
//顺便增加电源管理芯片
/include/ "tps65217.dtsi"
&tps {
regulators {
dcdc1_reg: regulator@0 {
// VDD_1V8 system supply
regulator-always-on;
};
// VDD_CORE voltage limits 0.95V - 1.26V with +/-4% tolerance
regulator-name = "vdd_core";
regulator-min-microvolt = <925000>;
regulator-max-microvolt = <1150000>;
regulator-boot-on;
regulator-always-on;
};
dcdc3_reg: regulator@2 {
// VDD_MPU voltage limits 0.95V - 1.1V with +/-4% tolerance
regulator-name = "vdd_mpu";
regulator-min-microvolt = <925000>;
regulator-max-microvolt = <1325000>;
regulator-boot-on;
regulator-always-on;
};
ldo1_reg: regulator@3 {
// VRTC 1.8V always-on supply
regulator-name = "vrtc,vdds";
regulator-always-on;
};
// 3.3V rail
regulator-name = "vdd_3v3aux";
regulator-always-on;
};
ldo3_reg: regulator@5 {
// VDD_3V3A 3.3V rail
regulator-name = "vdd_3v3a";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
ldo4_reg: regulator@6 {
// VDD_3V3B 3.3V rail
regulator-name = "vdd_3v3b";
regulator-always-on;
};
};
};
&mcasp0 {
#sound-dai-cells = <0>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&mcasp0_pins>;
pinctrl-1 = <&mcasp0_pins_sleep>;
status = "okay";
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
/* 4 serializers */
serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
0 0 1 2
>;
tx-num-evt = <32>;
rx-num-evt = <32>;
};
增加按键驱动:
gpio_keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&gpio_key_s0>;
#address-cells = <1>;
#size-cells = <0>;
button@1 {
debounce_interval = <50>;
linux,code = <105>;
label = "left";
gpios = <&gpio1 17 0x1>;
gpio-key,wakeup;
autorepeat;
};
button@2 {
debounce_interval = <50>;
linux,code = <106>;
label = "right";
gpios = <&gpio3 16 0x1>;
gpio-key,wakeup;
autorepeat;
};
button@3 {
debounce_interval = <50>;
linux,code = <103>;
label = "up";
gpios = <&gpio1 19 0x1>;
gpio-key,wakeup;
autorepeat;
};
button@4 {
debounce_interval = <50>;
linux,code = <108>;
label = "down";
gpios = <&gpio2 1 0x1>;
gpio-key,wakeup;
autorepeat;
};
button@5 {
debounce_interval = <50>;
linux,code = <28>;
label = "enter";
gpios = <&gpio0 3 0x1>;
gpio-key,wakeup;
};
button@6 {
debounce_interval = <50>;
linux,code = <1>;
label = "enter";
gpios = <&gpio0 5 0x1>;
gpio-key,wakeup;
};
button@9 {
debounce_interval = <50>;
linux,code = <115>;
label = "volume-up";
gpios = <&gpio0 2 0x1>;
gpio-key,wakeup;
autorepeat;
};
button@10 {
debounce_interval = <50>;
linux,code = <114>;
label = "volume-down";
gpios = <&gpio0 4 0x1>;
gpio-key,wakeup;
autorepeat;
};
};
每次更新驱动只需重新编译设备树文件即可,不必重新编译内核和模块,当然这里说的驱动只是在设备树上添加信息,真正的驱动代码还需要内核源文件的支持才可以,这可能是我下一步学习的重点了,还望大牛指正。
具体效果:
[media]http://player.youku.com/player.php/sid/XMzU4MTk2NjA3Ng==/v.swf[/media]
此内容由EEWORLD论坛网友anananjjj原创,如需转载或用于商业用途需征得作者同意并注明出处
本帖最后由 anananjjj 于 2018-5-4 07:41 编辑