rn5t618-regulator.c (0337966d121ebebf73a1c346123e8112796e684e) rn5t618-regulator.c (83b2a3c2ab24561cb6de45e6b155e3a7c4c1c91b)
1/*
2 * Regulator driver for Ricoh RN5T618 PMIC
3 *
4 * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.

--- 65 unchanged lines hidden (view full) ---

74 REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 600000, 3500000, 25000),
75 REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
76 REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 900000, 3500000, 25000),
77 /* LDO RTC */
78 REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000),
79 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
80};
81
1/*
2 * Regulator driver for Ricoh RN5T618 PMIC
3 *
4 * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.

--- 65 unchanged lines hidden (view full) ---

74 REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 600000, 3500000, 25000),
75 REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
76 REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 900000, 3500000, 25000),
77 /* LDO RTC */
78 REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000),
79 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
80};
81
82static struct regulator_desc rc5t619_regulators[] = {
83 /* DCDC */
84 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
85 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
86 REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500),
87 REG(DCDC4, DC4CTL, BIT(0), DC4DAC, 0xff, 600000, 3500000, 12500),
88 REG(DCDC5, DC5CTL, BIT(0), DC5DAC, 0xff, 600000, 3500000, 12500),
89 /* LDO */
90 REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000),
91 REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000),
92 REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 900000, 3500000, 25000),
93 REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
94 REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 600000, 3500000, 25000),
95 REG(LDO6, LDOEN1, BIT(5), LDO6DAC, 0x7f, 600000, 3500000, 25000),
96 REG(LDO7, LDOEN1, BIT(6), LDO7DAC, 0x7f, 900000, 3500000, 25000),
97 REG(LDO8, LDOEN1, BIT(7), LDO8DAC, 0x7f, 900000, 3500000, 25000),
98 REG(LDO9, LDOEN2, BIT(0), LDO9DAC, 0x7f, 900000, 3500000, 25000),
99 REG(LDO10, LDOEN2, BIT(0), LDO10DAC, 0x7f, 900000, 3500000, 25000),
100 /* LDO RTC */
101 REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000),
102 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
103};
104
82static int rn5t618_regulator_probe(struct platform_device *pdev)
83{
84 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
85 struct regulator_config config = { };
86 struct regulator_dev *rdev;
87 struct regulator_desc *regulators;
88 int i;
105static int rn5t618_regulator_probe(struct platform_device *pdev)
106{
107 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
108 struct regulator_config config = { };
109 struct regulator_dev *rdev;
110 struct regulator_desc *regulators;
111 int i;
112 int num_regulators = 0;
89
90 switch (rn5t618->variant) {
91 case RN5T567:
92 regulators = rn5t567_regulators;
113
114 switch (rn5t618->variant) {
115 case RN5T567:
116 regulators = rn5t567_regulators;
117 num_regulators = ARRAY_SIZE(rn5t567_regulators);
93 break;
94 case RN5T618:
95 regulators = rn5t618_regulators;
118 break;
119 case RN5T618:
120 regulators = rn5t618_regulators;
121 num_regulators = ARRAY_SIZE(rn5t618_regulators);
96 break;
122 break;
123 case RC5T619:
124 regulators = rc5t619_regulators;
125 num_regulators = ARRAY_SIZE(rc5t619_regulators);
126 break;
97 default:
98 return -EINVAL;
99 }
100
101 config.dev = pdev->dev.parent;
102 config.regmap = rn5t618->regmap;
103
127 default:
128 return -EINVAL;
129 }
130
131 config.dev = pdev->dev.parent;
132 config.regmap = rn5t618->regmap;
133
104 for (i = 0; i < RN5T618_REG_NUM; i++) {
105 if (!regulators[i].name)
106 continue;
107
134 for (i = 0; i < num_regulators; i++) {
108 rdev = devm_regulator_register(&pdev->dev,
109 &regulators[i],
110 &config);
111 if (IS_ERR(rdev)) {
112 dev_err(&pdev->dev, "failed to register %s regulator\n",
113 regulators[i].name);
114 return PTR_ERR(rdev);
115 }

--- 17 unchanged lines hidden ---
135 rdev = devm_regulator_register(&pdev->dev,
136 &regulators[i],
137 &config);
138 if (IS_ERR(rdev)) {
139 dev_err(&pdev->dev, "failed to register %s regulator\n",
140 regulators[i].name);
141 return PTR_ERR(rdev);
142 }

--- 17 unchanged lines hidden ---