nandflash_pins_default: nandflash_pins_default {
pinctrl-single,pins = <
0x6c ( PIN_OUTPUT | MUX_MODE0 ) /* (V17) gpmc_a11.gpmc_a11 */
0x68 ( PIN_OUTPUT | MUX_MODE0 ) /* (T16) gpmc_a10.gpmc_a10 */
0x64 ( PIN_OUTPUT | MUX_MODE0 ) /* (U16) gpmc_a9.gpmc_a9 */
0x60 ( PIN_OUTPUT | MUX_MODE0 ) /* (V16) gpmc_a8.gpmc_a8 */
0x5c ( PIN_OUTPUT | MUX_MODE0 ) /* (T15) gpmc_a7.gpmc_a7 */
0x58 ( PIN_OUTPUT | MUX_MODE0 ) /* (U15) gpmc_a6.gpmc_a6 */
0x54 ( PIN_OUTPUT | MUX_MODE0 ) /* (V15) gpmc_a5.gpmc_a5 */
0x50 ( PIN_OUTPUT | MUX_MODE0 ) /* (R14) gpmc_a4.gpmc_a4 */
0x4c ( PIN_OUTPUT | MUX_MODE0 ) /* (T14) gpmc_a3.gpmc_a3 */
0x48 ( PIN_OUTPUT | MUX_MODE0 ) /* (U14) gpmc_a2.gpmc_a2 */
0x44 ( PIN_OUTPUT | MUX_MODE0 ) /* (V14) gpmc_a1.gpmc_a1 */
0x40 ( PIN_OUTPUT | MUX_MODE0 ) /* (R13) gpmc_a0.gpmc_a0 */
0x3c ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (U13) gpmc_ad15.gpmc_ad15 */
0x38 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (V13) gpmc_ad14.gpmc_ad14 */
0x34 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (R12) gpmc_ad13.gpmc_ad13 */
0x30 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T12) gpmc_ad12.gpmc_ad12 */
0x2c ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (U12) gpmc_ad11.gpmc_ad11 */
0x28 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T11) gpmc_ad10.gpmc_ad10 */
0x24 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T10) gpmc_ad9.gpmc_ad9 */
0x20 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (U10) gpmc_ad8.gpmc_ad8 */
0x1c ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T9) gpmc_ad7.gpmc_ad7 */
0x18 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (R9) gpmc_ad6.gpmc_ad6 */
0x14 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (V8) gpmc_ad5.gpmc_ad5 */
0x10 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (U8) gpmc_ad4.gpmc_ad4 */
0xc ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T8) gpmc_ad3.gpmc_ad3 */
0x8 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (R8) gpmc_ad2.gpmc_ad2 */
0x4 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (V7) gpmc_ad1.gpmc_ad1 */
0x0 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (U7) gpmc_ad0.gpmc_ad0 */
0x70 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (T17) gpmc_wait0.gpmc_wait0 */
0x74 ( PIN_INPUT_PULLUP | MUX_MODE7 ) /* (U17) gpmc_wpn.gpmc_wpn */
0x7c ( PIN_OUTPUT | MUX_MODE0 ) /* gpmc_csn0.gpmc_csn0 */
0x80 ( PIN_OUTPUT | MUX_MODE0 ) /* (U9) gpmc_csn1.gpmc_csn1 */
0x84 ( PIN_OUTPUT | MUX_MODE0 ) /* (V9) gpmc_csn2.gpmc_csn2 */
0x88 ( PIN_OUTPUT | MUX_MODE0 ) /* (T13) gpmc_csn3.gpmc_csn3 */
0x8c ( PIN_OUTPUT | MUX_MODE0 ) /* (V12) gpmc_clk.gpmc_clk */
0x90 ( PIN_OUTPUT | MUX_MODE0 ) /* (R7) gpmc_advn_ale.gpmc_advn_ale */
0x94 ( PIN_OUTPUT | MUX_MODE0 ) /* (T7) gpmc_oen_ren.gpmc_oen_ren */
0x98 ( PIN_OUTPUT | MUX_MODE0 ) /* (U6) gpmc_wen.gpmc_wen */
0x9c ( PIN_OUTPUT | MUX_MODE0 ) /* (T6) gpmc_be0n_cle.gpmc_be0n_cle */
>;
};
&gpmc {
status = "okay";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&nandflash_pins_default>;
pinctrl-1 = <&nandflash_pins_sleep>;
ranges = <0 0 0x08000000 0x1000000>, /* CSn0: 16MB for NAND */
<1 0 0x01000000 0x1000000>; /* CSn1: 16MB for fpga */
nand@0,0 {
compatible = "ti,omap2-nand";
reg = <0 0 4>; /* CS0, offset 0, IO size 4 每个寄存器地址偏移4个字节*/
interrupt-parent = <&intc>;
interrupts = <100>;
ready-gpio = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */
ti,nand-ecc-opt = "bch8";
ti,elm-id = <&elm>;
nand-bus-width = <8>;
gpmc,device-width = <1>;
gpmc,sync-clk-ps = <0>;
gpmc,cs-on-ns = <0>;
gpmc,cs-rd-off-ns = <44>;
gpmc,cs-wr-off-ns = <44>;
gpmc,adv-on-ns = <6>;
gpmc,adv-rd-off-ns = <34>;
gpmc,adv-wr-off-ns = <44>;
gpmc,we-on-ns = <0>;
gpmc,we-off-ns = <40>;
gpmc,oe-on-ns = <0>;
gpmc,oe-off-ns = <54>;
gpmc,access-ns = <64>;
gpmc,rd-cycle-ns = <82>;
gpmc,wr-cycle-ns = <82>;
gpmc,bus-turnaround-ns = <0>;
gpmc,cycle2cycle-delay-ns = <0>;
gpmc,clk-activation-ns = <0>;
gpmc,wr-access-ns = <40>;
gpmc,wr-data-mux-bus-ns = <0>;
/* MTD partition table */
/* All SPL-* partitions are sized to minimal length
* which can be independently programmable. For
* NAND flash this is equal to size of erase-block */
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "NAND.SPL";
reg = <0x00000000 0x000020000>;
};
partition@1 {
label = "NAND.SPL.backup1";
reg = <0x00020000 0x00020000>;
};
partition@2 {
label = "NAND.SPL.backup2";
reg = <0x00040000 0x00020000>;
};
partition@3 {
label = "NAND.SPL.backup3";
reg = <0x00060000 0x00020000>;
};
partition@4 {
label = "NAND.u-boot-spl-os";
reg = <0x00080000 0x00040000>;
};
partition@5 {
label = "NAND.u-boot";
reg = <0x000C0000 0x00100000>;
};
partition@6 {
label = "NAND.u-boot-env";
reg = <0x001C0000 0x00020000>;
};
partition@7 {
label = "NAND.u-boot-env.backup1";
reg = <0x001E0000 0x00020000>;
};
partition@8 {
label = "NAND.kernel";
reg = <0x00200000 0x00800000>;
};
partition@9 {
label = "NAND.rootfs";
reg = <0x00A00000 0x07600000>;
};
partition@10 {
label = "NAND.userdata";
reg = <0x08000000 0x08000000>;
}; };
fpga@1,0 {
compatible = "fpga";
status = "okay";
reg = <1 0 0x1000000>; //第一个是片选 第二个是相对该片选的基地址 ,第三个是length容量
nor-bus-width = <16>;
bank-width = <2>; /* GPMC_CONFIG1_DEVICESIZE(1) */
gpmc,sync-read; /* GPMC_CONFIG1_READTYPE_ASYNC */
gpmc,sync-write; /* GPMC_CONFIG1_WRITETYPE_ASYNC */
gpmc,clk-activation-ns = <0>; /* GPMC_CONFIG1_CLKACTIVATIONTIME(2) */
// gpmc,burst-length = <16>; /* GPMC_CONFIG1_PAGE_LEN(2) */
// gpmc,mux-add-data = <2>; /* GPMC_CONFIG1_MUXTYPE(2) */
gpmc,mux-add-data = <0>; /* GPMC_CONFIG1_MUXTYPE(2) */
gpmc,sync-clk-ps = <20000>; /* CONFIG2 */
/********************************************************************/
gpmc,cs-on-ns = <0>;
gpmc,cs-rd-off-ns = <100>;
gpmc,cs-wr-off-ns = <40>;
gpmc,adv-on-ns = <0>; /* CONFIG3 */
gpmc,oe-on-ns = <20>;
gpmc,oe-off-ns = <100>;
gpmc,we-on-ns = <20>; /* CONFIG4 */
gpmc,we-off-ns = <40>;
gpmc,access-ns = <80>;
gpmc,rd-cycle-ns = <120>;
gpmc,wr-cycle-ns = <60>;
/*********************************************************************/ gpmc,adv-rd-off-ns = <20>;
gpmc,adv-wr-off-ns = <20>;
gpmc,page-burst-access-ns = <20>; /* CONFIG 5 */
gpmc,wr-access-ns = <40>; /* CONFIG 6 */
gpmc,wr-data-mux-bus-ns = <20>;
/*gpmc,bus-turnaround-ns = <40>;*/ /* CONFIG6:3:0 = 4 */
//gpmc,cycle2cycle-samecsen; /* CONFIG6:7 = 1 */
//gpmc,cycle2cycle-delay-ns = <20>; /* CONFIG6:11:8 = 4 */
/* not using dma engine yet, but we can get the channel number here */
};
};
问题有3:
1.这是dts里对fpga配置.整个配置对吗,在这里reg <1 0 0x1000000>这样写对吗,我把nand 和fpga的gpmc引脚配置在一起,这样处理对吗
2.dts里的时序配置如gpmc,oe-on-ns = <20>这些配置 和
#define STNOR_GPMC_CONFIG1 0x00001000
#define STNOR_GPMC_CONFIG2 0x0008080F
#define STNOR_GPMC_CONFIG3 0x001F1F0F
#define STNOR_GPMC_CONFIG4 0x010F010F
#define STNOR_GPMC_CONFIG5 0x00001F1F
#define STNOR_GPMC_CONFIG6 0x00000000
这里的时序配置有关吗 需要严格一致吗
3.编译后insmod fpga.ko 后通过printk打印报Failed request for GPMC mem for usrp_e错误.
原函数是
if ((gpmc_cs_request(GPMC_CS, SZ_4M, (unsigned long *)&mem_base) < 0)){
printk(KERN_ERR "Failed request for GPMC mem for usrp_e \n");
return -1;
}
这是什么情况造成的.望详细解答 万谢!
Jian Zhou:
FPGA的地址空间分配是怎么样的?这种错误应该是分配的地址空间不对。
另外你是想在NAND的驱动的架构上修改为FPGA么?
user4822185:
回复 Jian Zhou:
cs1分配空间0x01000000 0x01000000
嗯 在nand的驱动架构上修改,但两者都要用.都是物理存在的.
刚刚insmod成功了,但是执行测试应用程序报
# ls
fpgadev.kotest_fpgadev
# ./test_fpgadev
*****MYIR-FPGA GPMC Module Test******[314.185156] fpga_write*****Mar5 2018 09:55:57*****
[314.190852] fpga_read
[314.196175] Unhandled fault: external abort on non-linefetch (0x1028) at 0xe1201000
[314.204167] pgd = dc944000
[314.206989] [e1201000] *pgd=00211452(bad)
[314.211187] Internal error: : 1028 [#1] PREEMPT ARM
[314.216275] Modules linked in: fpgadev(O) ipv6 musb_dsps musb_hdrc udc_core evdev ti_am335x_adc usbcore joydev kfifo_buf industrialio pm33xx gpio_keys omap_aes_driver snd_soc_evm omap_sham omap_rng rng_core c_can_platform c_can can_dev snd_soc_sgtl5000 ti_am335x_tsc musb_am335x rtc_omap omap_wdt ti_am335x_tscadc leds_gpio
[314.246172] CPU: 0 PID: 171 Comm: test_fpgadev Tainted: GO4.1.18 #2
[314.254069] Hardware name: Generic AM33XX (Flattened Device Tree)
[314.260425] task: dc925b00 ti: dd876000 task.ti: dd876000
[314.266071] PC is at fpga_write+0x11c/0x150 [fpgadev]
[314.271360] LR is at __schedule+0x1c4/0x4c0
[314.275725] pc : [<bf1c81a4>]lr : [<c063b550>]psr: 20070013
[314.275725] sp : dd877eb0ip : dd877d98fp : dd877ed4
[314.287706] r10: 00000000r9 : 00000014r8 : bf1c8728
[314.293155] r7 : 00000000r6 : bf1c8728r5 : 00000014r4 : 00000014
[314.299965] r3 : 00000000r2 : e1201000r1 : 00000000r0 : e1000000
[314.306777] Flags: nzCvIRQs onFIQs onMode SVC_32ISA ARMSegment user
[314.314220] Control: 10c5387dTable: 9c944019DAC: 00000015
[314.320214] Process test_fpgadev (pid: 171, stack limit = 0xdd876210)
[314.326932] Stack: (0xdd877eb0 to 0xdd878000)
[314.331479] 7ea0:dd877f78 ddd219c0 bf1c8088 00000014
[314.340016] 7ec0: dd877f78 bee7ecac dd877f44 dd877ed8 c0106798 bf1c8094 dd877f0c dd877ee8
[314.348552] 7ee0: c029f420 c02a043c 00000000 dd072220 dc808950 ddd219c0 00000014 00000014
[314.357088] 7f00: dd877f44 dd877f10 c0106de4 c029f404 ddc4a000 00000003 ddc4a000 ddd219c0
[314.365624] 7f20: ddd219c0 00000014 bee7ecac dd877f78 bee7ecac 00000014 dd877f74 dd877f48
[314.374159] 7f40: c0107054 c0106770 c010617c c0115b64 dd877f74 ddd219c0 ddd219c0 00000000
[314.382693] 7f60: 00000000 bee7ecac dd877fa4 dd877f78 c010789c c0106fc8 00000000 00000000
[314.391228] 7f80: 000084fd 00000000 00008381 00000004 c000fa84 dd876000 00000000 dd877fa8
[314.399763] 7fa0: c000f8e0 c0107864 000084fd 00000000 00000003 bee7ecac 00000014 bee7ecac
[314.408299] 7fc0: 000084fd 00000000 00008381 00000004 00000000 00000000 b6fef000 00000000
[314.416832] 7fe0: 00000000 bee7ec94 000084e7 b6f43a70 60070010 00000003 3183aac9 10012852
[314.425360] Backtrace:
[314.427935] [<bf1c8088>] (fpga_write [fpgadev]) from [<c0106798>] (__vfs_write+0x34/0xe4)
[314.436466]r8:bee7ecac r7:dd877f78 r6:00000014 r5:bf1c8088 r4:ddd219c0 r3:dd877f78
[314.444572] [<c0106764>] (__vfs_write) from [<c0107054>] (vfs_write+0x98/0x178)
[314.452193]r9:00000014 r8:bee7ecac r7:dd877f78 r6:bee7ecac r5:00000014 r4:ddd219c0
[314.460299] [<c0106fbc>] (vfs_write) from [<c010789c>] (SyS_write+0x44/0x98)
[314.467647]r8:bee7ecac r7:00000000 r6:00000000 r5:ddd219c0 r4:ddd219c0
[314.474673] [<c0107858>] (SyS_write) from [<c000f8e0>] (ret_fast_syscall+0x0/0x3c)
[314.482565]r9:dd876000 r8:c000fa84 r7:00000004 r6:00008381 r5:00000000 r4:000084fd
[314.490670] Code: e1a01003 ea000004 e5960054 e0802002 (e1d200b0)
[314.497030] —[ end trace 8bb16b9e6563e5a8 ]—
Segmentation fault 错误..不知哪儿的问题.