Lines Matching +full:bb +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
26 * - If the voltage on a rail is above the "1.8" voltage (1.98V) we'll tell the
28 * - If the voltage on a rail is above the "3.3" voltage (3.6V) we'll consider
75 int (*write)(struct rockchip_iodomain_supply *supply, int uV);
83 int (*write)(struct rockchip_iodomain_supply *supply, int uV);
86 static int rk3568_iodomain_write(struct rockchip_iodomain_supply *supply, int uV) in rk3568_iodomain_write() argument
88 struct rockchip_iodomain *iod = supply->iod; in rk3568_iodomain_write()
93 switch (supply->idx) { in rk3568_iodomain_write()
97 b = supply->idx; in rk3568_iodomain_write()
99 b = supply->idx + 4; in rk3568_iodomain_write()
102 regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val0); in rk3568_iodomain_write()
103 regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val1); in rk3568_iodomain_write()
113 b = supply->idx - 1; in rk3568_iodomain_write()
117 regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL0, val0); in rk3568_iodomain_write()
118 regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL1, val1); in rk3568_iodomain_write()
121 return -EINVAL; in rk3568_iodomain_write()
127 static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply, in rockchip_iodomain_write() argument
130 struct rockchip_iodomain *iod = supply->iod; in rockchip_iodomain_write()
136 val <<= supply->idx; in rockchip_iodomain_write()
138 /* apply hiword-mask */ in rockchip_iodomain_write()
139 val |= (BIT(supply->idx) << 16); in rockchip_iodomain_write()
141 ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val); in rockchip_iodomain_write()
143 dev_err(iod->dev, "Couldn't write to GRF\n"); in rockchip_iodomain_write()
152 struct rockchip_iodomain_supply *supply = in rockchip_iodomain_notify() local
173 uV = max_t(unsigned long, pvc_data->old_uV, pvc_data->max_uV); in rockchip_iodomain_notify()
181 dev_dbg(supply->iod->dev, "Setting to %d\n", uV); in rockchip_iodomain_notify()
184 dev_err(supply->iod->dev, "Voltage too high: %d\n", uV); in rockchip_iodomain_notify()
190 ret = supply->iod->write(supply, uV); in rockchip_iodomain_notify()
194 dev_dbg(supply->iod->dev, "Setting to %d done\n", uV); in rockchip_iodomain_notify()
203 /* if no VCCIO6 supply we should leave things alone */ in px30_iodomain_init()
204 if (!iod->supplies[PX30_IO_VSEL_VCCIO6_SUPPLY_NUM].reg) in px30_iodomain_init()
212 ret = regmap_write(iod->grf, PX30_IO_VSEL, val); in px30_iodomain_init()
214 dev_warn(iod->dev, "couldn't update vccio6 ctrl\n"); in px30_iodomain_init()
222 /* if no flash supply we should leave things alone */ in rk3288_iodomain_init()
223 if (!iod->supplies[RK3288_SOC_FLASH_SUPPLY_NUM].reg) in rk3288_iodomain_init()
231 ret = regmap_write(iod->grf, RK3288_SOC_CON2, val); in rk3288_iodomain_init()
233 dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); in rk3288_iodomain_init()
241 /* if no vccio3 supply we should leave things alone */ in rk3308_iodomain_init()
242 if (!iod->supplies[RK3308_SOC_VCCIO3_SUPPLY_NUM].reg) in rk3308_iodomain_init()
250 ret = regmap_write(iod->grf, RK3308_SOC_CON0, val); in rk3308_iodomain_init()
252 dev_warn(iod->dev, "couldn't update vccio3 vsel ctrl\n"); in rk3308_iodomain_init()
260 /* if no vccio2 supply we should leave things alone */ in rk3328_iodomain_init()
261 if (!iod->supplies[RK3328_SOC_VCCIO2_SUPPLY_NUM].reg) in rk3328_iodomain_init()
269 ret = regmap_write(iod->grf, RK3328_SOC_CON4, val); in rk3328_iodomain_init()
271 dev_warn(iod->dev, "couldn't update vccio2 vsel ctrl\n"); in rk3328_iodomain_init()
279 /* if no flash supply we should leave things alone */ in rk3368_iodomain_init()
280 if (!iod->supplies[RK3368_SOC_FLASH_SUPPLY_NUM].reg) in rk3368_iodomain_init()
288 ret = regmap_write(iod->grf, RK3368_SOC_CON15, val); in rk3368_iodomain_init()
290 dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); in rk3368_iodomain_init()
298 /* if no pmu io supply we should leave things alone */ in rk3399_pmu_iodomain_init()
299 if (!iod->supplies[RK3399_PMUGRF_VSEL_SUPPLY_NUM].reg) in rk3399_pmu_iodomain_init()
307 ret = regmap_write(iod->grf, RK3399_PMUGRF_CON0, val); in rk3399_pmu_iodomain_init()
309 dev_warn(iod->dev, "couldn't update pmu io iodomain ctrl\n"); in rk3399_pmu_iodomain_init()
322 "vccio-oscgpi",
350 * On the rk3188 the io-domains are handled by a shared register with the
351 * lower 8 bits being still being continuing drive-strength settings.
393 "bb", /* APIO5_VDD */
548 .compatible = "rockchip,px30-io-voltage-domain",
552 .compatible = "rockchip,px30-pmu-io-voltage-domain",
556 .compatible = "rockchip,rk3188-io-voltage-domain",
560 .compatible = "rockchip,rk3228-io-voltage-domain",
564 .compatible = "rockchip,rk3288-io-voltage-domain",
568 .compatible = "rockchip,rk3308-io-voltage-domain",
572 .compatible = "rockchip,rk3328-io-voltage-domain",
576 .compatible = "rockchip,rk3368-io-voltage-domain",
580 .compatible = "rockchip,rk3368-pmu-io-voltage-domain",
584 .compatible = "rockchip,rk3399-io-voltage-domain",
588 .compatible = "rockchip,rk3399-pmu-io-voltage-domain",
592 .compatible = "rockchip,rk3568-pmu-io-voltage-domain",
596 .compatible = "rockchip,rv1108-io-voltage-domain",
600 .compatible = "rockchip,rv1108-pmu-io-voltage-domain",
604 .compatible = "rockchip,rv1126-pmu-io-voltage-domain",
613 struct device_node *np = pdev->dev.of_node; in rockchip_iodomain_probe()
620 return -ENODEV; in rockchip_iodomain_probe()
622 iod = devm_kzalloc(&pdev->dev, sizeof(*iod), GFP_KERNEL); in rockchip_iodomain_probe()
624 return -ENOMEM; in rockchip_iodomain_probe()
626 iod->dev = &pdev->dev; in rockchip_iodomain_probe()
630 iod->soc_data = match->data; in rockchip_iodomain_probe()
632 if (iod->soc_data->write) in rockchip_iodomain_probe()
633 iod->write = iod->soc_data->write; in rockchip_iodomain_probe()
635 iod->write = rockchip_iodomain_write; in rockchip_iodomain_probe()
637 parent = pdev->dev.parent; in rockchip_iodomain_probe()
638 if (parent && parent->of_node) { in rockchip_iodomain_probe()
639 iod->grf = syscon_node_to_regmap(parent->of_node); in rockchip_iodomain_probe()
641 dev_dbg(&pdev->dev, "falling back to old binding\n"); in rockchip_iodomain_probe()
642 iod->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_iodomain_probe()
645 if (IS_ERR(iod->grf)) { in rockchip_iodomain_probe()
646 dev_err(&pdev->dev, "couldn't find grf regmap\n"); in rockchip_iodomain_probe()
647 return PTR_ERR(iod->grf); in rockchip_iodomain_probe()
651 const char *supply_name = iod->soc_data->supply_names[i]; in rockchip_iodomain_probe()
652 struct rockchip_iodomain_supply *supply = &iod->supplies[i]; in rockchip_iodomain_probe() local
659 reg = devm_regulator_get_optional(iod->dev, supply_name); in rockchip_iodomain_probe()
663 /* If a supply wasn't specified, that's OK */ in rockchip_iodomain_probe()
664 if (ret == -ENODEV) in rockchip_iodomain_probe()
666 else if (ret != -EPROBE_DEFER) in rockchip_iodomain_probe()
667 dev_err(iod->dev, "couldn't get regulator %s\n", in rockchip_iodomain_probe()
677 dev_err(iod->dev, "Can't determine voltage: %s\n", in rockchip_iodomain_probe()
684 dev_crit(iod->dev, in rockchip_iodomain_probe()
687 ret = -EINVAL; in rockchip_iodomain_probe()
691 /* setup our supply */ in rockchip_iodomain_probe()
692 supply->idx = i; in rockchip_iodomain_probe()
693 supply->iod = iod; in rockchip_iodomain_probe()
694 supply->reg = reg; in rockchip_iodomain_probe()
695 supply->nb.notifier_call = rockchip_iodomain_notify; in rockchip_iodomain_probe()
697 ret = iod->write(supply, uV); in rockchip_iodomain_probe()
699 supply->reg = NULL; in rockchip_iodomain_probe()
704 ret = regulator_register_notifier(reg, &supply->nb); in rockchip_iodomain_probe()
706 dev_err(&pdev->dev, in rockchip_iodomain_probe()
708 supply->reg = NULL; in rockchip_iodomain_probe()
713 if (iod->soc_data->init) in rockchip_iodomain_probe()
714 iod->soc_data->init(iod); in rockchip_iodomain_probe()
719 for (i = MAX_SUPPLIES - 1; i >= 0; i--) { in rockchip_iodomain_probe()
720 struct rockchip_iodomain_supply *io_supply = &iod->supplies[i]; in rockchip_iodomain_probe()
722 if (io_supply->reg) in rockchip_iodomain_probe()
723 regulator_unregister_notifier(io_supply->reg, in rockchip_iodomain_probe()
724 &io_supply->nb); in rockchip_iodomain_probe()
735 for (i = MAX_SUPPLIES - 1; i >= 0; i--) { in rockchip_iodomain_remove()
736 struct rockchip_iodomain_supply *io_supply = &iod->supplies[i]; in rockchip_iodomain_remove()
738 if (io_supply->reg) in rockchip_iodomain_remove()
739 regulator_unregister_notifier(io_supply->reg, in rockchip_iodomain_remove()
740 &io_supply->nb); in rockchip_iodomain_remove()
748 .name = "rockchip-iodomain",
755 MODULE_DESCRIPTION("Rockchip IO-domain driver");