diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/regulator/ab8500.c | 102 |
1 files changed, 8 insertions, 94 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 603f192e84f1..0f86695b737a 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
| @@ -2998,37 +2998,6 @@ static void abx500_get_regulator_info(struct ab8500 *ab8500) | |||
| 2998 | } | 2998 | } |
| 2999 | } | 2999 | } |
| 3000 | 3000 | ||
| 3001 | static int ab8500_regulator_init_registers(struct platform_device *pdev, | ||
| 3002 | int id, int mask, int value) | ||
| 3003 | { | ||
| 3004 | struct ab8500_reg_init *reg_init = abx500_regulator.init; | ||
| 3005 | int err; | ||
| 3006 | |||
| 3007 | BUG_ON(value & ~mask); | ||
| 3008 | BUG_ON(mask & ~reg_init[id].mask); | ||
| 3009 | |||
| 3010 | /* initialize register */ | ||
| 3011 | err = abx500_mask_and_set_register_interruptible( | ||
| 3012 | &pdev->dev, | ||
| 3013 | reg_init[id].bank, | ||
| 3014 | reg_init[id].addr, | ||
| 3015 | mask, value); | ||
| 3016 | if (err < 0) { | ||
| 3017 | dev_err(&pdev->dev, | ||
| 3018 | "Failed to initialize 0x%02x, 0x%02x.\n", | ||
| 3019 | reg_init[id].bank, | ||
| 3020 | reg_init[id].addr); | ||
| 3021 | return err; | ||
| 3022 | } | ||
| 3023 | dev_vdbg(&pdev->dev, | ||
| 3024 | " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", | ||
| 3025 | reg_init[id].bank, | ||
| 3026 | reg_init[id].addr, | ||
| 3027 | mask, value); | ||
| 3028 | |||
| 3029 | return 0; | ||
| 3030 | } | ||
| 3031 | |||
| 3032 | static int ab8500_regulator_register(struct platform_device *pdev, | 3001 | static int ab8500_regulator_register(struct platform_device *pdev, |
| 3033 | struct regulator_init_data *init_data, | 3002 | struct regulator_init_data *init_data, |
| 3034 | int id, struct device_node *np) | 3003 | int id, struct device_node *np) |
| @@ -3095,9 +3064,7 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
| 3095 | { | 3064 | { |
| 3096 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | 3065 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
| 3097 | struct device_node *np = pdev->dev.of_node; | 3066 | struct device_node *np = pdev->dev.of_node; |
| 3098 | struct ab8500_platform_data *ppdata; | 3067 | int err; |
| 3099 | struct ab8500_regulator_platform_data *pdata; | ||
| 3100 | int i, err; | ||
| 3101 | 3068 | ||
| 3102 | if (!ab8500) { | 3069 | if (!ab8500) { |
| 3103 | dev_err(&pdev->dev, "null mfd parent\n"); | 3070 | dev_err(&pdev->dev, "null mfd parent\n"); |
| @@ -3106,68 +3073,15 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
| 3106 | 3073 | ||
| 3107 | abx500_get_regulator_info(ab8500); | 3074 | abx500_get_regulator_info(ab8500); |
| 3108 | 3075 | ||
| 3109 | if (np) { | 3076 | err = of_regulator_match(&pdev->dev, np, |
| 3110 | err = of_regulator_match(&pdev->dev, np, | 3077 | abx500_regulator.match, |
| 3111 | abx500_regulator.match, | 3078 | abx500_regulator.match_size); |
| 3112 | abx500_regulator.match_size); | 3079 | if (err < 0) { |
| 3113 | if (err < 0) { | 3080 | dev_err(&pdev->dev, |
| 3114 | dev_err(&pdev->dev, | 3081 | "Error parsing regulator init data: %d\n", err); |
| 3115 | "Error parsing regulator init data: %d\n", err); | ||
| 3116 | return err; | ||
| 3117 | } | ||
| 3118 | |||
| 3119 | err = ab8500_regulator_of_probe(pdev, np); | ||
| 3120 | return err; | ||
| 3121 | } | ||
| 3122 | |||
| 3123 | ppdata = dev_get_platdata(ab8500->dev); | ||
| 3124 | if (!ppdata) { | ||
| 3125 | dev_err(&pdev->dev, "null parent pdata\n"); | ||
| 3126 | return -EINVAL; | ||
| 3127 | } | ||
| 3128 | |||
| 3129 | pdata = ppdata->regulator; | ||
| 3130 | if (!pdata) { | ||
| 3131 | dev_err(&pdev->dev, "null pdata\n"); | ||
| 3132 | return -EINVAL; | ||
| 3133 | } | ||
| 3134 | |||
| 3135 | /* make sure the platform data has the correct size */ | ||
| 3136 | if (pdata->num_regulator != abx500_regulator.info_size) { | ||
| 3137 | dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); | ||
| 3138 | return -EINVAL; | ||
| 3139 | } | ||
| 3140 | |||
| 3141 | /* initialize debug (initial state is recorded with this call) */ | ||
| 3142 | err = ab8500_regulator_debug_init(pdev); | ||
| 3143 | if (err) | ||
| 3144 | return err; | 3082 | return err; |
| 3145 | |||
| 3146 | /* initialize registers */ | ||
| 3147 | for (i = 0; i < pdata->num_reg_init; i++) { | ||
| 3148 | int id, mask, value; | ||
| 3149 | |||
| 3150 | id = pdata->reg_init[i].id; | ||
| 3151 | mask = pdata->reg_init[i].mask; | ||
| 3152 | value = pdata->reg_init[i].value; | ||
| 3153 | |||
| 3154 | /* check for configuration errors */ | ||
| 3155 | BUG_ON(id >= abx500_regulator.init_size); | ||
| 3156 | |||
| 3157 | err = ab8500_regulator_init_registers(pdev, id, mask, value); | ||
| 3158 | if (err < 0) | ||
| 3159 | return err; | ||
| 3160 | } | ||
| 3161 | |||
| 3162 | /* register all regulators */ | ||
| 3163 | for (i = 0; i < abx500_regulator.info_size; i++) { | ||
| 3164 | err = ab8500_regulator_register(pdev, &pdata->regulator[i], | ||
| 3165 | i, NULL); | ||
| 3166 | if (err < 0) | ||
| 3167 | return err; | ||
| 3168 | } | 3083 | } |
| 3169 | 3084 | return ab8500_regulator_of_probe(pdev, np); | |
| 3170 | return 0; | ||
| 3171 | } | 3085 | } |
| 3172 | 3086 | ||
| 3173 | static int ab8500_regulator_remove(struct platform_device *pdev) | 3087 | static int ab8500_regulator_remove(struct platform_device *pdev) |
