Advertisement
Guest User

board_p940.c

a guest
Nov 28th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.75 KB | None | 0 0
  1. /* P940 board_p940.c by wkpark at gmail.com */
  2.  
  3. #include <aboot/aboot.h>
  4. #include <aboot/io.h>
  5. #include <omap4/mux.h>
  6. #include <omap4/hw.h>
  7. #include <omap4/omap4_rom.h>
  8. #include <omap4/smc.h>
  9.  
  10. #if 0
  11. #define PL310_POR       5
  12. #define PPA_SERVICE_PL310_POR   0x23
  13. #define PUBLIC_API_SEC_ENTRY    0x00
  14.  
  15. typedef u32 (** const PUBLIC_SEC_ENTRY_Pub2SecDispatcher_pt) \
  16.                (u32 appl_id, u32 proc_ID, u32 flag, ...);
  17. #define omap_smc_ppa \
  18.       (*(PUBLIC_SEC_ENTRY_Pub2SecDispatcher_pt) \
  19.                                    (PUBLIC_API_BASE_4430+PUBLIC_API_SEC_ENTRY))
  20.  
  21. #define IVA_LDOSRAM_VOLTAGE_CTRL    0x4A002320
  22. #define MPU_LDOSRAM_VOLTAGE_CTRL    0x4A002324
  23. #define CORE_LDOSRAM_VOLTAGE_CTRL   0x4A002328
  24. #define SYSCTRL_PADCONF_CORE_EFUSE_1    0x4A100700
  25. #define SYSCTRL_PADCONF_CORE_EFUSE_2    0x4A100704
  26.  
  27. u32 get_device_type(void)
  28. {
  29.         /*
  30.          * Retrieve the device type: GP/EMU/HS/TST stored in
  31.          * CONTROL_STATUS
  32.          */
  33.         return (readl(CONTROL_STATUS) & DEVICE_MASK) >> 8;
  34. }
  35. #endif
  36.  
  37. void board_late_init(void)
  38. {
  39.     unsigned int rev = get_omap_rev();
  40.  
  41.     cfg_machine_type = 5001;
  42.  
  43.     if (rev != OMAP4430_ES1_0) {
  44.         if (readl(0x4805D138) & (1<<22)) {
  45.             /* enable software ioreq */
  46.             sr32(0x4A30a31C, 8, 1, 0x1);
  47.             /* set for sys_clk (38.4MHz) */
  48.             sr32(0x4A30a31C, 1, 2, 0x0);
  49.             /* set divisor to 2 */
  50.             sr32(0x4A30a31C, 16, 4, 0x1);
  51.             /* set the clock source to active */
  52.             sr32(0x4A30a110, 0, 1, 0x1);
  53.             /* enable clocks */
  54.             sr32(0x4A30a110, 2, 2, 0x3);
  55.         } else {
  56.             /* enable software ioreq */
  57.             sr32(0x4A30a314, 8, 1, 0x1);
  58.             /* set for PER_DPLL */
  59.             sr32(0x4A30a314, 1, 2, 0x2);
  60.             /* set divisor to 16 */
  61.             sr32(0x4A30a314, 16, 4, 0xf);
  62.             /* set the clock source to active */
  63.             sr32(0x4A30a110, 0, 1, 0x1);
  64.             /* enable clocks */
  65.             sr32(0x4A30a110, 2, 2, 0x3);
  66.         }
  67.     }
  68.  
  69. #if 0
  70.     if (rev > OMAP4430_ES1_0 && get_device_type() != GP_DEVICE) {
  71.                 /* Set PL310 Prefetch Offset Register w/PPA svc*/
  72.                 omap_smc_ppa(PPA_SERVICE_PL310_POR, 0, 0x7, 1, PL310_POR);
  73.                 /* Enable L2 data prefetch */
  74.                 omap_smc_rom(ROM_SERVICE_PL310_AUXCR_SVC,
  75.                         readl(OMAP44XX_PL310_AUX_CTRL) | 0x10000000);
  76.         } else if (rev > OMAP4430_ES2_1) {
  77.                 /* Set PL310 Prefetch Offset Register using ROM svc */
  78.                 omap_smc_rom(ROM_SERVICE_PL310_POR_SVC, PL310_POR);
  79.                 /* Enable L2 data prefetch */
  80.                 omap_smc_rom(ROM_SERVICE_PL310_AUXCR_SVC,
  81.                         readl(OMAP44XX_PL310_AUX_CTRL) | 0x10000000);
  82.         }
  83. #endif
  84.  
  85. #if 0
  86.     /* For ES2.2
  87.      * 1. If unit does not have SLDO trim, set override
  88.      * and force max multiplication factor to ensure
  89.      * proper SLDO voltage at low OPP's
  90.      * 2. Trim VDAC value for TV out as recomended to avoid
  91.      * potential instabilities at low OPP's
  92.      * 3.For all ESx.y trimmed and untrimmed units
  93.      * Override efuse with LPDDR P:16/N:16 and
  94.      * smart IO P:0/N:0 as per recomendation
  95.      */
  96.     // LGE_START 20110514++ need to check
  97.     //writel(0x00084000, SYSCTRL_PADCONF_CORE_EFUSE_2);
  98.     // LGE_END   20110514--
  99.     if (rev >= OMAP4430_ES2_2) {
  100.         /*if MPU_VOLTAGE_CTRL is 0x0 unit is not trimmed*/
  101.         if (!readl(IVA_LDOSRAM_VOLTAGE_CTRL)) {
  102.             /* Set M factor to max (2.7) */
  103.             writel(0x0401040f, IVA_LDOSRAM_VOLTAGE_CTRL);
  104.             writel(0x0401040f, MPU_LDOSRAM_VOLTAGE_CTRL);
  105.             writel(0x0401040f, CORE_LDOSRAM_VOLTAGE_CTRL);
  106.             // LGE_START 20110514++ need to check
  107.             //writel(0x000001c0, SYSCTRL_PADCONF_CORE_EFUSE_1);
  108.             // LGE_END   20110514--
  109.         }
  110.     }
  111. #endif
  112. }
  113.  
  114. void board_mux_init(void)
  115. {
  116.     /* from board_tuna.c and the disassembled x-load.bin of the SU540 */
  117.     MV(CP(UART4_RX), (IEN | PTU | M0)); /* uart4_rx */
  118.     MV(CP(UART4_TX), (M0));         /* uart4_tx */
  119.  
  120.     MV(CP(GPMC_NOE), (PTU | IEN | OFF_EN | M1));            /* sdmmc2_clk */
  121.     MV(CP(GPMC_NWE), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_cmd */
  122.  
  123.     MV(CP(GPMC_AD0), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat0 */
  124.     MV(CP(GPMC_AD1), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat1 */
  125.     MV(CP(GPMC_AD2), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat2 */
  126.     MV(CP(GPMC_AD3), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat3 */
  127.     MV(CP(GPMC_AD4), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat4 */
  128.     MV(CP(GPMC_AD5), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat5 */
  129.     MV(CP(GPMC_AD6), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat6 */
  130.     MV(CP(GPMC_AD7), (PTU | IEN | OFF_EN | OFF_PU | OFF_IN | M1));  /* sdmmc2_dat7 */
  131. }
  132.  
  133. const struct ddr_regs ddr_regs_533mhz_2cs = {
  134.     /* obtained by them devmem2 */
  135.     .tim1       = 0x10EB0661, /* x-loader verified */
  136.     .tim2       = 0x20370DD2,
  137.     .tim3       = 0x00B1C33F,
  138.     .phy_ctrl_1 = 0x049FF409, /* x-loader verified */
  139.     .ref_ctrl   = 0x00000618,
  140. #if defined(CONFIG_DDR_512MB)
  141.         .config_init    = 0x80000eb1,
  142.         .config_final   = 0x80001ab1,
  143. #else
  144.     .config_init    = 0x80000eb2,
  145.     .config_final   = 0x80001ab2,
  146. #endif
  147.     .zq_config  = 0x500B3214,
  148.     .mr1        = 0x83,
  149.     .mr2        = 0x4,
  150. };
  151.  
  152.  
  153. void board_ddr_init(void)
  154. {
  155.     writel(0x80640300, DMM_BASE + DMM_LISA_MAP_0); // x-loader confirmed 07/19
  156.     writel(0x00000000, DMM_BASE + DMM_LISA_MAP_2); // x-loader confirmed
  157.     writel(0xFF020100, DMM_BASE + DMM_LISA_MAP_3); // x-loader confirmed
  158.  
  159.     writel(0x7c7c7c7c, 0x4A100638); /* obtained from the devmen2 */
  160.     writel(0x7c7c7c7c, 0x4A10063c);
  161.     writel(0x7c7c7c7c, 0x4A100640);
  162.     writel(0x7c7c7c7c, 0x4A100648);
  163.     writel(0x7c7c7c7c, 0x4A10064c);
  164.     writel(0x7c7c7c7c, 0x4A100650);
  165.  
  166.     writel(0xa388bc03, 0x4A100644);
  167.     writel(0xa388bc03, 0x4A100654);
  168.  
  169.     omap4_ddr_init(&ddr_regs_533mhz_2cs,
  170.                &ddr_regs_533mhz_2cs);
  171.  
  172.     writel(0x0, 0x80000000); // x-loader confirmed
  173.     writel(0x0, 0x80000080); // x-loader confirmed
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement