rn5t618-regulator.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | rn5t618-regulator.c (ed6d362d8dbc3494cd98cd771737ea8b1407ed61) |
---|---|
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. --- 32 unchanged lines hidden (view full) --- 41 .min_uV = (min), \ 42 .uV_step = (step), \ 43 .enable_reg = RN5T618_##ereg, \ 44 .enable_mask = (emask), \ 45 .vsel_reg = RN5T618_##vreg, \ 46 .vsel_mask = (vmask), \ 47 } 48 | 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. --- 32 unchanged lines hidden (view full) --- 41 .min_uV = (min), \ 42 .uV_step = (step), \ 43 .enable_reg = RN5T618_##ereg, \ 44 .enable_mask = (emask), \ 45 .vsel_reg = RN5T618_##vreg, \ 46 .vsel_mask = (vmask), \ 47 } 48 |
49static struct regulator_desc rn5t567_regulators[] = { 50 /* DCDC */ 51 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), 52 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), 53 REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500), 54 REG(DCDC4, DC4CTL, BIT(0), DC4DAC, 0xff, 600000, 3500000, 12500), 55 /* LDO */ 56 REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000), 57 REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000), 58 REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 600000, 3500000, 25000), 59 REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000), 60 REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 900000, 3500000, 25000), 61 /* LDO RTC */ 62 REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1200000, 3500000, 25000), 63 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), 64}; 65 |
|
49static struct regulator_desc rn5t618_regulators[] = { 50 /* DCDC */ 51 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), 52 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), 53 REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500), 54 /* LDO */ 55 REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000), 56 REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000), --- 5 unchanged lines hidden (view full) --- 62 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), 63}; 64 65static int rn5t618_regulator_probe(struct platform_device *pdev) 66{ 67 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); 68 struct regulator_config config = { }; 69 struct regulator_dev *rdev; | 66static struct regulator_desc rn5t618_regulators[] = { 67 /* DCDC */ 68 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), 69 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), 70 REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500), 71 /* LDO */ 72 REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000), 73 REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000), --- 5 unchanged lines hidden (view full) --- 79 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), 80}; 81 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; |
|
70 int i; 71 | 88 int i; 89 |
90 switch (rn5t618->variant) { 91 case RN5T567: 92 regulators = rn5t567_regulators; 93 break; 94 case RN5T618: 95 regulators = rn5t618_regulators; 96 break; 97 default: 98 return -EINVAL; 99 } 100 101 config.dev = pdev->dev.parent; 102 config.regmap = rn5t618->regmap; 103 |
|
72 for (i = 0; i < RN5T618_REG_NUM; i++) { | 104 for (i = 0; i < RN5T618_REG_NUM; i++) { |
73 config.dev = pdev->dev.parent; 74 config.regmap = rn5t618->regmap; | 105 if (!regulators[i].name) 106 continue; |
75 76 rdev = devm_regulator_register(&pdev->dev, | 107 108 rdev = devm_regulator_register(&pdev->dev, |
77 &rn5t618_regulators[i], | 109 ®ulators[i], |
78 &config); 79 if (IS_ERR(rdev)) { 80 dev_err(&pdev->dev, "failed to register %s regulator\n", | 110 &config); 111 if (IS_ERR(rdev)) { 112 dev_err(&pdev->dev, "failed to register %s regulator\n", |
81 rn5t618_regulators[i].name); | 113 regulators[i].name); |
82 return PTR_ERR(rdev); 83 } 84 } 85 86 return 0; 87} 88 89static struct platform_driver rn5t618_regulator_driver = { 90 .probe = rn5t618_regulator_probe, 91 .driver = { 92 .name = "rn5t618-regulator", 93 }, 94}; 95 96module_platform_driver(rn5t618_regulator_driver); 97 98MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); 99MODULE_DESCRIPTION("RN5T618 regulator driver"); 100MODULE_LICENSE("GPL v2"); | 114 return PTR_ERR(rdev); 115 } 116 } 117 118 return 0; 119} 120 121static struct platform_driver rn5t618_regulator_driver = { 122 .probe = rn5t618_regulator_probe, 123 .driver = { 124 .name = "rn5t618-regulator", 125 }, 126}; 127 128module_platform_driver(rn5t618_regulator_driver); 129 130MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); 131MODULE_DESCRIPTION("RN5T618 regulator driver"); 132MODULE_LICENSE("GPL v2"); |