int pmic_bus_init(void) { /* This cannot be 0 because it is used in SPL before BSS is ready */ static int needs_init = 1; __maybe_unused int ret; if (!needs_init) return 0; #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER # ifdef CONFIG_MACH_SUN6I p2wi_init(); ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR, AXP221_INIT_DATA); # else ret = rsb_init(); if (ret) return ret; ret = rsb_set_device_address(AXP223_DEVICE_ADDR, AXP223_RUNTIME_ADDR); # endif if (ret) return ret; #endif needs_init = 0; return 0; }
int sunxi_pmic_setup(uint16_t socid, const void *fdt) { int ret; switch (socid) { case SUNXI_SOC_H5: pmic = REF_DESIGN_H5; NOTICE("BL31: PMIC: Defaulting to PortL GPIO according to H5 reference design.\n"); break; case SUNXI_SOC_A64: pmic = GENERIC_A64; ret = sunxi_init_platform_r_twi(socid, true); if (ret) return ret; ret = rsb_init(); if (ret) return ret; pmic = AXP803_RSB; NOTICE("BL31: PMIC: Detected AXP803 on RSB.\n"); if (fdt) setup_axp803_rails(fdt); break; default: NOTICE("BL31: PMIC: No support for Allwinner %x SoC.\n", socid); return -ENODEV; } return 0; }
void __dead2 sunxi_power_down(void) { switch (pmic) { case GENERIC_H5: /* Turn off as many peripherals and clocks as we can. */ sunxi_turn_off_soc(SUNXI_SOC_H5); /* Turn off the pin controller now. */ mmio_write_32(SUNXI_CCU_BASE + 0x68, 0); break; case GENERIC_A64: /* Turn off as many peripherals and clocks as we can. */ sunxi_turn_off_soc(SUNXI_SOC_A64); /* Turn off the pin controller now. */ mmio_write_32(SUNXI_CCU_BASE + 0x68, 0); break; case REF_DESIGN_H5: sunxi_turn_off_soc(SUNXI_SOC_H5); /* * Switch PL pins to power off the board: * - PL5 (VCC_IO) -> high * - PL8 (PWR-STB = CPU power supply) -> low * - PL9 (PWR-DRAM) ->low * - PL10 (power LED) -> low * Note: Clearing PL8 will reset the board, so keep it up. */ sunxi_set_gpio_out('L', 5, 1); sunxi_set_gpio_out('L', 9, 0); sunxi_set_gpio_out('L', 10, 0); /* Turn off pin controller now. */ mmio_write_32(SUNXI_CCU_BASE + 0x68, 0); break; case AXP803_RSB: /* (Re-)init RSB in case the rich OS has disabled it. */ sunxi_init_platform_r_twi(SUNXI_SOC_A64, true); rsb_init(); /* Set "power disable control" bit */ axp_setbits(0x32, BIT(7)); break; default: break; } udelay(1000); ERROR("PSCI: Cannot turn off system, halting.\n"); wfi(); panic(); }
/* * The axp221 uses the p2wi bus, the axp223 is identical (for all registers * used sofar) but uses the rsb bus. These functions abstract this. */ static int pmic_bus_init(void) { #ifdef CONFIG_MACH_SUN6I p2wi_init(); return p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR, AXP221_INIT_DATA); #else int ret; rsb_init(); ret = rsb_set_device_mode(AXP223_DEVICE_MODE_DATA); if (ret) return ret; return rsb_set_device_address(AXP223_DEVICE_ADDR, AXP223_RUNTIME_ADDR); #endif }