.. _SD.Bootloader.ControllerProdConfig:

.. include:: /content/swdocs.rsts

.. spelling::
   AO
   BootROM
   BR
   BCT
   dts
   coldboot
   CPU
   BL
   tegrabct
   tegrabct_v2
   Mem
   MB1
   MB2
   OEM
   FW
   SW
   VF
   HSM
   SC7
   SC8
   Watchdog
   PMIC
   OTP
   L1
   L2
   addr
   Ao
   AoBlock
   aoblock
   aotag
   hsm
   preinstalled
   sc
   vfsensor
   deviceprod
   prod
   cells
   qspi
   ddr
   SDMMC
   sdmmc
   TX
   RX
   DQS
   se
   hs
   tuples
   bct
   
   
   
   
Controller Product Configuration
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

The prod configurations are the system-characterized values of the interface and controller settings, which allow an interface to work reliably for a platform. The prod configurations are set separately at the controller and pinmux/pad levels. This file contains the controller-level prod settings.

The DTS configuration file is in the following format:

.. code-block:: none

   /{
     deviceprod {
		<controller-name>-<Instance> = <&Label>; 
		#prod-cells = <N>;
	    <Label>: <controller-name>@<base-address> {
	        <mode> {
		        prod = <<address offset> <mask> <value>>;
	        };
	    
        };
     };
	}; 

where:

- ``Instance`` is controller instance id.
- ``Label`` is the label assigned to the node which can be referenced for mapping instance to a node.
- ``<controller-name>`` is predefined module name (sdmmc, qspi, se, i2c).
- ``<base-address>`` is base address of the controller.
- ``<mode>`` is controller mode for which the prod setting needs to be applied (e.g. default, hs400, and so on).
- ``<address offset>`` is the register address offset from base address of the controller/instance
- ``<mask>`` is the mask value (4 bytes, unsigned).
- ``<value>`` is the data value (4 bytes, unsigned).
- ``N`` specifies how many entries are there on the prod setting tuples per configurations.

  - if #prod-cells equals 3, there are three entries per prod configuration, which are ``address _offset``, ``mask``, and ``value``.

The legacy config format used the device instance ``<controller-name>.<instance-index>`` instead of the base address of the device. The legacy format keeps one byte to store the instance but the new DTS format will have base address that requires four bytes in the BCT. As a result, some of the fields in the BCT structure have to be shifted accordingly.

For each entry in the prod configuration file, MB1 reads data from the specified address, modifies the data based on mask and value, and then writes the data back to the address:

.. code-block:: none

	val = read(address)
	val = (val & ~mask) | (value & mask); 
	write(val, address);
	...

The common prod configuration file is in the ``hardware/nvidia/platform/t23x/<platform>/bct/`` directory. 

Here is the new DTS example of a prod configuration file:

.. code-block:: none

   /dts-v1/;
    / {
	    deviceprod {
		    qspi-0 = <&qspi0>; 
		    qspi-1 = <&qspi1>; 
		    sdmmc-3 = <&sdmmc3>;

		    #prod-cells = <0x3>; 
			
		    qspi0: qspi@3270000 {
			    default  {
				    prod = <0x00000004 0x7C00 0x0>,
					       <0x00000004 0xFF 0x10>;
			    };
		    };
		    qspi1: qspi@3300000 { 
			    default {
				    prod = <0x00000004 0x7C00 0x0>,
					       <0x00000004 0xFF 0x10>;
			    };
		    };
		    sdmmc3: sdmmc@3460000 { 
			    default {
				    prod = <0x000001e4 0x00003FFF 0x0>;
			    };
			    hs400 {
				    prod = <0x00000100 0x1FFF0000 0x14080000>,
					       <0x0000010c 0x00003F00 0x00000028>;
			    };
			    ddr52 {
				    prod = <0x00000100 0x1FFF0000 0x14080000>;
			    };
		    };
	    };
   };
  
Here is the previous CFG format:

.. code-block:: none

   //Qspi0
   deviceprod.qspi.0.default.0x03270004.0x7C00 = 0x0 //TX Trimmer 
   deviceprod.qspi.0.default.0x03270004.0xFF = 0x10 //RX Trimmer

   //Qspi1
   deviceprod.qspi.1.default.0x03300004.0x7C00 = 0x0 //TX Trimmer 
   deviceprod.qspi.1.default.0x03300004.0xFF = 0x10 //RX Trimmer

   //SDMMC
   deviceprod.sdmmc.3.default.0x034601e4.0x00003FFF = 0x0 // auto cal pd and pu offsets 
   deviceprod.sdmmc.3.hs400.0x03460100.0x1FFF0000 = 0x14080000 // tap and trim values 
   deviceprod.sdmmc.3.hs400.0x0346010c.0x00003F00 = 0x00000028 // DQS trim val 
   deviceprod.sdmmc.3.ddr52.0x03460100.0x1FFF0000 = 0x14080000 // tap and trim values