Device tree - Parallel interface using HSMC

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

KevinWysocki
Posts: 9
Joined: Wed Aug 22, 2018 5:20 pm

Device tree - Parallel interface using HSMC

Fri Aug 24, 2018 11:48 am

Dear,

I am trying to use the static memory controller to drive a device using a "lightweight" parallel interface (only a chip select and 9-bit data lines). I want to use nCS0, to map my device @ 0x10000000 and D0 to D8 data lines. So far, I use a SAMA5D2 Xplained demo board with Linux4SAM v5.8.

For now, I have a test program from userspace which allows me to read/write to peripheral registers, using mmap(), so I can configure HSMC and write value @ 0x10000000. This works, I can see chip select and data lines on a scope.

Now, I would like to use my device tree file to configure EBI and HSMC drivers and add my "memory" so I will not have to configure the peripheral registers manually. But I am a bit lost. I found this document: https://github.com/linux4sam/linux-at91 ... %2Cebi.txt

So I added EBI, HSMC definitions in sama5d2.dtsi (based on linux mainline sama5d2.dtsi from https://github.com/torvalds/linux ), pinctrl to configure PA22 to PA26 (I use only 5 data lines for now, I will modify the board to use the other bits later) , and PC5 to alternate function and I tried to add the example from the Atmel EBI DT documentation. So, it looks like :

My user DTSI

Code: Select all

ebi: ebi@10000000 {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_dev_smc_default>;
			
			dev: flash@0,0 {
				compatible = "cfi-flash";
				#address-cells = <1>;
				#size-cells = <1>;
				reg = <0x0 0x0 0x1>;		/* Use nCS0, size is 1 byte */

				atmel,smc-read-mode = "ncs";
				atmel,smc-write-mode = "ncs";
				atmel,smc-bus-width = <8>;
				atmel,smc-ncs-rd-setup-ns = <0>;
				atmel,smc-ncs-wr-setup-ns = <0>;
				atmel,smc-nwe-setup-ns = <8>;
				atmel,smc-nrd-setup-ns = <16>;
				atmel,smc-ncs-rd-pulse-ns = <84>;
				atmel,smc-ncs-wr-pulse-ns = <84>;
				atmel,smc-nrd-pulse-ns = <76>;
				atmel,smc-nwe-pulse-ns = <76>;
				atmel,smc-nrd-cycle-ns = <107>;
				atmel,smc-nwe-cycle-ns = <84>;
				atmel,smc-tdf-ns = <16>;
			};
		};
		
		...
		
		pinctrl_dev_smc_default: io_dev{
					pinmux = <PIN_PA22__D0>,
							 <PIN_PA23__D1>,
							 <PIN_PA24__D2>,
							 <PIN_PA25__D3>,
							 <PIN_PA26__D4>,
							 <PIN_PC5__NCS0>;
						bias-disable;
				};
		
sama5d2.dtsi

Code: Select all

ebi: ebi@10000000 {
			compatible = "atmel,sama5d3-ebi";
			#address-cells = <2>;
			#size-cells = <1>;
			atmel,smc = <&hsmc>;
			reg = <0x10000000 0x10000000
			       0x60000000 0x30000000>;
			ranges = <0x0 0x0 0x10000000 0x10000000
				  0x1 0x0 0x60000000 0x10000000
				  0x2 0x0 0x70000000 0x10000000
				  0x3 0x0 0x80000000 0x10000000>;
			clocks = <&mck>;
			status = "disabled";

			nand_controller: nand-controller {
				compatible = "atmel,sama5d3-nand-controller";
				atmel,nfc-sram = <&nfc_sram>;
				atmel,nfc-io = <&nfc_io>;
				ecc-engine = <&pmecc>;
				#address-cells = <2>;
				#size-cells = <1>;
				ranges;
				status = "disabled";
			};
		};
		
		...
		
		hsmc: hsmc@f8014000 {
				compatible = "atmel,sama5d2-smc", "syscon", "simple-mfd";
				reg = <0xf8014000 0x1000>;
				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 6>;
				clocks = <&hsmc_clk>;
				#address-cells = <1>;
				#size-cells = <1>;
				ranges;

				pmecc: ecc-engine@f8014070 {
					compatible = "atmel,sama5d2-pmecc";
					reg = <0xf8014070 0x490>,
					      <0xf8014500 0x100>;
				};
			};		
		
... Surprise ! It doesn't work !

At least, HSMC clock is not enabled (PID17 in PCM_PCSR0 is reset) and HSMC settings are not modified (bus is 16-bit wide, wrong timings, etc.). The only thing in the DTSI that works is the pinctrl part.

So, where am I wrong ? Anybody already had such kind of application working ?

Thanks,

Kevin
blue_z
Location: USA
Posts: 1907
Joined: Thu Apr 19, 2007 10:15 pm

Re: Device tree - Parallel interface using HSMC

Fri Aug 24, 2018 11:58 pm

KevinWysocki wrote:So I added EBI, HSMC definitions in sama5d2.dtsi (based on linux mainline sama5d2.dtsi from https://github.com/torvalds/linux ), ...
The sama5d2.dtsi file describes the generic SoC as manufactured by Microchip.
Since you cannot modify the chip itself, do not modify this file.
You are making customizations at the board level, so these modified nodes belong in your board's .dts file.

Mainline Linux kernel as of today is at version 4.18.
You made an ambiguous reference to "Linux4SAM v5.8". The Linux kernel associated with Linux4SAM v5.8 is linux-at91 version 4.9.
Are you trying to merge DT properties from different kernel versions (as well as different source trees)?

KevinWysocki wrote:My user DTSI...
What is a "user dtsi"?
Where is it in the order of included files?


KevinWysocki wrote:So, where am I wrong ?
If you're actually using the linux-at91 4.9 kernel, then there is no driver in that kernel version that will satisfy the compatible property of "atmel,sama5d2-smc" that you imported from the mainline kernel.
You cannot blindly copy-n-paste Device Tree nodes/properties from other kernel versions/trees.

Regards
KevinWysocki
Posts: 9
Joined: Wed Aug 22, 2018 5:20 pm

Re: Device tree - Parallel interface using HSMC

Mon Aug 27, 2018 9:02 am

blue_z wrote:
Fri Aug 24, 2018 11:58 pm
The sama5d2.dtsi file describes the generic SoC as manufactured by Microchip.
Since you cannot modify the chip itself, do not modify this file.
You are making customizations at the board level, so these modified nodes belong in your board's .dts file.

Mainline Linux kernel as of today is at version 4.18.
You made an ambiguous reference to "Linux4SAM v5.8". The Linux kernel associated with Linux4SAM v5.8 is linux-at91 version 4.9.
Are you trying to merge DT properties from different kernel versions (as well as different source trees)?
Yes, I am. EBI peripheral for SAMA5D2 is mentionned as compatibe in Linux4SAM v5.8 device tree documentation (so, as you said, based on Linux Kernel v4.9) but not included in sama5d2.dsti. So I tried to include it and make it work.

blue_z wrote:
Fri Aug 24, 2018 11:58 pm
What is a "user dtsi"? Where is it in the order of included files?
Basically, I have a modified device tree file (based on at91-sama5d2_xplained_common.dtsi from Linux4SAM package), where I added some application related definitions, which includes sama5d2.dtsi (from Linux4SAM package, with the EBI and HSMC definitions added from Linux Kernel 4.18).

blue_z wrote:
Fri Aug 24, 2018 11:58 pm
If you're actually using the linux-at91 4.9 kernel, then there is no driver in that kernel version that will satisfy the compatible property of "atmel,sama5d2-smc" that you imported from the mainline kernel.
You cannot blindly copy-n-paste Device Tree nodes/properties from other kernel versions/trees.
Indeed, I made some research last friday and I figured out SMC compatibility SAMA5D2 chips has been introduced in Linux Kernel 4.13. So, for now, I will have to continue to configure HSMC manually.
blue_z
Location: USA
Posts: 1907
Joined: Thu Apr 19, 2007 10:15 pm

Re: Device tree - Parallel interface using HSMC

Fri Aug 31, 2018 1:18 am

KevinWysocki wrote: So, for now, I will have to continue to configure HSMC manually.
No, you do not "have to" use such a kludge.
You could choose to use the DT bindings for ebi appropriate for kernel version 4.9 that you cited.
But you must not adulterate the DT with properties from 4.18, only need to modify the board file. i.e. the .dts file, and should avoid modifying shared .dtsi files.
And of course use the appropriate compatible string for your board's ebi node.

Regards
gselabs
Posts: 10
Joined: Sun Feb 17, 2019 7:04 pm

Re: Device tree - Parallel interface using HSMC

Sun Feb 17, 2019 7:29 pm

So, for now, I will have to continue to configure HSMC manually.
Had you have any luck with the HSMC/EBI?
Which device type were you tried to connect?

Currently I am looking for a possibility to use the EBI with a NAND (on which rootfs resides among the boot loader, the kernel image and rest) and a small LCD with a parallel interface (also known as the MCU 8080 parallel interface). The classical LCDC usage is too pin consumable solution in such case. The SPI one is too slow.

Would it be a problem to use the Atmel's EBI driver in such configuration? There is no HW incompatibility as I have checked it but I have been stuck with linux related stuff.
KevinWysocki
Posts: 9
Joined: Wed Aug 22, 2018 5:20 pm

Re: Device tree - Parallel interface using HSMC

Mon Feb 18, 2019 3:05 pm

gselabs wrote:
Sun Feb 17, 2019 7:29 pm
Had you have any luck with the HSMC/EBI?
Which device type were you tried to connect?

Currently I am looking for a possibility to use the EBI with a NAND (on which rootfs resides among the boot loader, the kernel image and rest) and a small LCD with a parallel interface (also known as the MCU 8080 parallel interface). The classical LCDC usage is too pin consumable solution in such case. The SPI one is too slow.

Would it be a problem to use the Atmel's EBI driver in such configuration? There is no HW incompatibility as I have checked it but I have been stuck with linux related stuff.
With Linux4SAM 5.8 no, I had to configure HSMC registers "manually" to get it work (kernel version was too old to add support for SAMA5D27, only SAMA5D3). But since Linux4SAM 6.0, bus timings, bank width and I/O are configured with my custom device tree file.

It was a simple 8-bit data bus with a few control lines to drive some logic. I have no worry that you could control a LCD controller with a parallel interface through HSMC.
gselabs
Posts: 10
Joined: Sun Feb 17, 2019 7:04 pm

Re: Device tree - Parallel interface using HSMC

Mon Feb 18, 2019 4:32 pm

KevinWysocki wrote:
Mon Feb 18, 2019 3:05 pm
With Linux4SAM 5.8 no, I had to configure HSMC registers "manually" to get it work (kernel version was too old to add support for SAMA5D27, only SAMA5D3). But since Linux4SAM 6.0, bus timings, bank width and I/O are configured with my custom device tree file.

It was a simple 8-bit data bus with a few control lines to drive some logic. I have no worry that you could control a LCD controller with a parallel interface through HSMC.
I have to multiplex NAND and LCD on EBI and concern about simultaneous usage of the peripheral by different software components.

Do you use NAND flash on EBI via NFC? Could you share some details about your EBI configuration? DTS file? Thanks.
KevinWysocki
Posts: 9
Joined: Wed Aug 22, 2018 5:20 pm

Re: Device tree - Parallel interface using HSMC

Tue Feb 19, 2019 9:33 am

gselabs wrote:
Mon Feb 18, 2019 4:32 pm
I have to multiplex NAND and LCD on EBI and concern about simultaneous usage of the peripheral by different software components.

Do you use NAND flash on EBI via NFC? Could you share some details about your EBI configuration? DTS file? Thanks.
No, I don't use NAND flash but a eMMC through SDMMC interface. Here is a part of my DTS file :

Code: Select all

ebi: ebi@10000000 {
	compatible = "atmel,sama5d3-ebi";
	#address-cells = <2>;
	#size-cells = <1>;
	atmel,smc = <&hsmc>;
	reg = <0x10000000 0x10000000
	            0x60000000 0x30000000>;
	ranges = <0x0 0x0 0x10000000 0x10000000
			  0x1 0x0 0x60000000 0x10000000
			  0x2 0x0 0x70000000 0x10000000
			  0x3 0x0 0x80000000 0x10000000>;
	clocks = <&mck>;
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_bus_smc_default>;	
			
	bus: bus@0,0 {
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0x0 0x0 0x1000000>;
		bank-width = <2>;
		atmel,smc-read-mode = "ncs";
		atmel,smc-write-mode = "ncs";
		atmel,smc-bus-width = <16>;
		atmel,smc-ncs-rd-setup-ns = <6>;
		atmel,smc-ncs-rd-pulse-ns = <18>;
		atmel,smc-ncs-wr-setup-ns = <6>;
		atmel,smc-ncs-wr-pulse-ns = <18>;				
		atmel,smc-nwe-setup-ns = <0>;
		atmel,smc-nwe-pulse-ns = <0>;
		atmel,smc-nrd-setup-ns = <0>;
		atmel,smc-nrd-pulse-ns = <0>;				
		atmel,smc-nrd-cycle-ns = <30>;
		atmel,smc-nwe-cycle-ns = <30>;
		atmel,smc-tdf-ns = <0>;
	};
};

.....

pinctrl_bus_smc_default: io_bus{
			pinmux = <PIN_PA22__D0>,	// D0
					 <PIN_PA23__D1>,	// D1
					 <PIN_PA24__D2>,	// D2
					 <PIN_PA25__D3>,	// D3
					 <PIN_PA26__D4>,	// D4
					 <PIN_PA27__D5>,	// D5	
					 <PIN_PA28__D6>,	// D6 
					 <PIN_PA29__D7>,	// nLATCH
					 <PIN_PB5__D10>,	// STROBE_VALID
					 <PIN_PB6__D11>,	// nCLKEN
					 <PIN_PC5__NCS0>;	// CLK
					bias-disable;
			};

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 1 guest