11 Replies Latest reply on Sep 20, 2019 2:34 AM by GernotH_31

    Linux patch for S70GL02GS

    SrWu_4394436

      Hi,

      We have received a linux patch file “linux-3.14.27-s70gl02gs.patch.zip” from BushraH_91 on Aug 7, 2019 3:10 PM in the below discussion.

       

      https://community.cypress.com/thread/48218?start=0&tstart=0

       

      S70GL02GS is being detected as 128 MB on our custom board.  Towards this we have few questions on the patch file:

       

      Is the patch applicable for Linux version 4.14?

      On which version of Linux version was this patch validated?

       

      Regards

      Srinivasa

        • 1. Re: Linux patch for S70GL02GS
          GernotH_31

          Hi Srinivasa,

           

          the patch contains just 8 new lines of code. It should be easy to add these to any Linux kernel version.

          However, if you want, I can create a patch for another specific kernel version (4.14?).

           

          Thanks

          Gernot

          • 2. Re: Linux patch for S70GL02GS
            SrWu_4394436

            Hi Gernot,

             

            We don't have problem in adding the patch to Linux 4.14.  We have already added it.

             

            Since we are facing below two problems,

            • Kernel is detecting the flash as 128 MB only..
            • In kernel, able to write less than or equal to one sector size (128 Kbyte) eg.) 100 Kbytes file using flashcp command and we could see that data is being written by cat /dev/mtdX command. Writing a file larger than one sector size (128 Kbyte) is also corrupting first sector data.

             

            Whereas in bootloader we are able to write more than 1 sector size file. 

             

            Looking at our problem satement,

            my question is "Is this patch applicable for Linux 4.14 also?"

             

            If you have any hint on above two problem statement please let us know.

             

            Regards

            Srinivasa

             

            • 3. Re: Linux patch for S70GL02GS
              GernotH_31

              Hi Srinivasa,

               

              yes, that patch is applicable to 4.14 as well.

               

              I think there is a misunderstanding here. The S70GL02GS has 2 internal 1 Gb (128 MB) chips. These chips need to be probed separately in Linux (2 flchip structs). The patch reduces the CFI size from 2 Gb to 1 Gb. Then you need to probe both chips from your board driver. Looks like in you case only 1 chip is probed.

               

              How does your board driver code look like where you call cfi_probe()? How large is the memory mapped window? And what kernel messages do you get when the part is probed?

               

              Best regards,

              Gernot

              • 4. Re: Linux patch for S70GL02GS
                SrWu_4394436

                Hi Gernot,

                 

                Thank you very much for your fast response.

                 

                Kernel boot message states “number of CFI chips: 1”.

                 

                [    2.202642] Correcting S70GL02GS CFI data

                [    2.206722] MY, my_partitions: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x004801

                [    2.217464] Amd/Fujitsu Extended Query Table at 0x0040

                [    2.222702] Amd/Fujitsu Extended Query version 1.5.

                [    2.227810] number of CFI chips: 1

                [    2.232171] 6 ofpart partitions found on MTD device MY, My_partitions

                [    2.238847] Creating 6 MTD partitions on "MY, My_partitions":

                [    2.245005] 0x000000000000-0x000000080000 : "uboot"

                [    2.252282] 0x000000080000-0x0000000a0000 : "uboot-env"

                [    2.259471] 0x0000000a0000-0x0000005a0000 : "Current kernel"

                [    2.267350] 0x0000005a0000-0x000000aa0000 : "Backup kernel"

                [    2.275044] 0x000000aa0000-0x000000fa0000 : "Failsafe kernel"

                [    2.282872] 0x000000fa0000-0x000010000000 : "File System"

                [    2.288328] mtd: partition "File System" extends beyond the end of device "MY, my_partitions" -- size truncated to 0x7060000

                 

                 

                We are using the driver that has come with Linux 4.14 and we have not modified anything (just applied the patch provided by you).

                To probe the two chips, do we need to add additional code in the Linux driver?

                Memory mapped window has a provision for mapping up to 512 MB of external memory.

                 

                Please find the kernel log messages attached.

                 

                Regards

                Srinivasa

                • 5. Re: Linux patch for S70GL02GS
                  GernotH_31

                  Hi Srinivasa,

                   

                  I have just checked with a S70GL02GS on 4.14, after applying the patch (it could be applied to 4.14. without any issues).

                  I am passing a 256 MB mapped address window to cfi_probe. Then the correct probing messages are:

                   

                  Sep 18 13:06:22 muc-cse-01 kernel: Correcting S70GL02GS CFI data

                  Sep 18 13:06:22 muc-cse-01 kernel: NOR: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x0022e7

                  Sep 18 13:06:22 muc-cse-01 kernel: NOR: Found 1 x16 devices at 0x8000000 in 16-bit bank

                  Sep 18 13:06:22 muc-cse-01 kernel: Amd/Fujitsu Extended Query Table at 0x0040

                  Sep 18 13:06:22 muc-cse-01 kernel:  Amd/Fujitsu Extended Query version 1.3.

                  Sep 18 13:06:22 muc-cse-01 kernel: number of CFI chips: 2

                   

                  $ cat /proc/mtd

                  dev:    size   erasesize  name

                  mtd0: 10000000 00020000 "NOR"

                   

                  Best regards,

                  Gernot

                  • 6. Re: Linux patch for S70GL02GS
                    SrWu_4394436

                    Hi Gernot,

                     

                    Please share the code snippet how you have passing a 256 MB mapped address window to cfi_probe.

                    I am hard time doing so.

                     

                    Regards

                    Srinivasa

                    • 7. Re: Linux patch for S70GL02GS
                      GernotH_31

                      struct map_info   *map;

                      ...

                      membank->size = pci_resource_len(dev, i);     // 256 MB

                      ...

                      membank->baseaddr = ioremap(membank->base, membank->size);

                      ...

                      map->name = "NOR";

                      map->phys = membank->base;

                      map->size = membank->size;

                      map->virt = membank->baseaddr;

                      map->bankwidth = 2;

                      simple_map_init(map);

                      ...

                      membank->mtd = do_map_probe("cfi_probe", map);

                      • 8. Re: Linux patch for S70GL02GS
                        SrWu_4394436

                        Hi Gernot,

                         

                        Thanks for the code snippet.

                         

                        As of now my system is detecting 128 MB and below message is being displayed.

                        MY, My_partitions: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x004801.

                        and you have additional below line.

                        Sep 18 13:06:22 muc-cse-01 kernel: NOR: Found 1 x16 devices at 0x8000000 in 16-bit bank

                         

                        Function cfi_cmdset_0002() in file drivers/mtd/chips/cfi_cmdset_0002.c is being executed by the kernel. This function gets information about struct map_info *map and assigned to the MTD driver.

                        Towards detecting the 128 MB of the chip I have not done any modifications in the kernel, only DTS file is being updated.

                         

                        My understanding was that we are NOT required to do any modifications at the code level.  We need to update only the DTS file and everything will be taken care by the existing driver/kernel.

                         

                        But from the code snippet you have shared, now I impression that I need to update the driver code and register with the kernel for detecting second die.  Is this correct?

                         

                        I need some more input on the code snippet you have shared.

                        Where are you adding the above code snippet?  Is it possible for you to share the complete file, so that I can add at my end?

                         

                        Regards

                        Srinivasa

                        • 9. Re: Linux patch for S70GL02GS
                          GernotH_31

                          Hi Srvinivasa,

                           

                          the code if from a PCI card driver.

                           

                          You need to do something similar in your board driver. What CPU and board are you using? Where is do_map_probe() being issued in your environment? How does your DTS entry look like? Maybe you are using the physmap driver!? Or something BSP (TI?) specific? This part is really board specific. And of course addressing 256 MB of flash needs to be supported by the hardware (controller and also wiring/PCB).

                           

                          Best regards,

                          Gernot

                          • 10. Re: Linux patch for S70GL02GS
                            SrWu_4394436

                            Hi Gernot,

                             

                            We have AM3352 processor connected to S70GL02GS on the GPMC (General Purpose Memory Controller).

                             

                            Probing is done from below function:

                             

                            cfi_probe() : First function to be called when the driver is loaded, defined in drivers/mtd/chips/cfi_probe.c

                            mtd_do_chip_probe() ->define in drivers/mtd/chips/gen_probe.c

                            check_cmd_set () ->  define in drivers/mtd/chips/gen_probe.c

                            cfi_cmdset_0002() defined in drivers/mtd/chips/cfi_cmdset_0002.c

                             

                            Most of the MTD related initialization, callback registrations, and probing of chips happens here.

                             

                            All the input goes to cfi_probe () from the dts file.

                             

                            I am having hard time in completing the dts file related to S70GL02GS.

                            My Kernel log is as below and I have attached my nor flash related dts file.

                             

                            [    5.598635] Amd/Fujitsu Extended Query version 1.5.

                            [    5.603728] Silicon revision: 14

                            [    5.607191] Address sensitive unlock: Required

                            [    5.611840] Erase Suspend: Read/write

                            [    5.615738] Block protection: 1 sectors per group

                            [    5.620649] Temporary block unprotect: Not supported

                            [    5.625853] Block protect/unprotect scheme: 8

                            [    5.630414] Number of simultaneous operations: 0

                            [    5.635268] Burst mode: Not supported

                            [    5.639132] Page mode: 12 word page

                            [    5.642820] Vpp Supply Minimum Program/Erase Voltage: 0.0 V

                            [    5.648634] Vpp Supply Maximum Program/Erase Voltage: 0.0 V

                            [    5.654417] Top/Bottom Boot Block: Uniform, Top WP

                            [    5.659452] number of CFI chips: 1

                            [    5.662899]

                            [    5.662899]

                            [    5.662899]

                            [    5.662899] Srini debug @ line 127 in function of_get_probes in file drivers/mtd/maps/physmap_of_core.c

                            [    5.662899]

                            [    5.662899]

                            [    5.680705] 6 ofpart partitions found on MTD device SPX, SPX_partitions

                            [    5.687566] Creating 6 MTD partitions on "MY, My_partitions":

                            [    5.693552] 0x000000000000-0x000000080000 : "uboot"

                            [    5.700871] 0x000000080000-0x0000000a0000 : "uboot-env"

                            [    5.708398] 0x0000000a0000-0x0000005a0000 : "Current kernel"

                            [    5.716192] 0x0000005a0000-0x000000aa0000 : "Backup kernel"

                            [    5.723722] 0x000000aa0000-0x000000fa0000 : "Failsafe kernel"

                            [    5.731587] 0x000000fa0000-0x000010000000 : "File System"

                            [    5.737127] mtd: partition "File System" extends beyond the end of device "SPX, SPX_partitions" -- size truncated to 0x7060000

                            [    5.750484]

                             

                            All input to cfi_probe function is coming from dts file.

                             

                            Problem: number of CFI chips: 1. 

                            How do I tell kernel in dts file that I have two die(chips) in my NOR flash S70GL02GS?

                            I tried with device-width = < 2 >; still the number of chips is 1.

                            What are other parameters that I need to pass to kernel in dts related to NOR flash?

                             

                            Please I need your help/support in completing dts file on the NOR flash side.

                             

                            Regards

                            Srinivasa

                            • 11. Re: Linux patch for S70GL02GS
                              GernotH_31

                              Hi Srinivasa,

                               

                              in your case the ti,am3352-gpmc driver is your board driver and is probably taking care of the mapping and calling cfi_probe.

                               

                              cfi_probe analyzes the provided memory window. If it finds a device and if the memory window is larger than the device size it is probing again at the address range above the first device for additional ones. So no need to call cfi_probe twice from within the board driver.

                               

                              Best regards,

                              Gernot