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: 4
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: 1716
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: 4
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: 1716
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

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests