• Home
  • Raw
  • Download

Lines Matching +full:ast2400 +full:- +full:adc

2  * Aspeed AST2400/2500 ADC
13 #include <linux/clk-provider.h>
100 of_device_get_match_data(data->dev); in aspeed_adc_read_raw()
104 *val = readw(data->base + chan->address); in aspeed_adc_read_raw()
108 *val = model_data->vref_voltage; in aspeed_adc_read_raw()
113 *val = clk_get_rate(data->clk_scaler->clk) / in aspeed_adc_read_raw()
118 return -EINVAL; in aspeed_adc_read_raw()
128 of_device_get_match_data(data->dev); in aspeed_adc_write_raw()
132 if (val < model_data->min_sampling_rate || in aspeed_adc_write_raw()
133 val > model_data->max_sampling_rate) in aspeed_adc_write_raw()
134 return -EINVAL; in aspeed_adc_write_raw()
136 clk_set_rate(data->clk_scaler->clk, in aspeed_adc_write_raw()
148 return -EPERM; in aspeed_adc_write_raw()
151 return -EINVAL; in aspeed_adc_write_raw()
162 return -EINVAL; in aspeed_adc_reg_access()
164 *readval = readl(data->base + reg); in aspeed_adc_reg_access()
185 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*data)); in aspeed_adc_probe()
187 return -ENOMEM; in aspeed_adc_probe()
190 data->dev = &pdev->dev; in aspeed_adc_probe()
193 data->base = devm_ioremap_resource(&pdev->dev, res); in aspeed_adc_probe()
194 if (IS_ERR(data->base)) in aspeed_adc_probe()
195 return PTR_ERR(data->base); in aspeed_adc_probe()
197 /* Register ADC clock prescaler with source specified by device tree. */ in aspeed_adc_probe()
198 spin_lock_init(&data->clk_lock); in aspeed_adc_probe()
199 clk_parent_name = of_clk_get_parent_name(pdev->dev.of_node, 0); in aspeed_adc_probe()
201 data->clk_prescaler = clk_hw_register_divider( in aspeed_adc_probe()
202 &pdev->dev, "prescaler", clk_parent_name, 0, in aspeed_adc_probe()
203 data->base + ASPEED_REG_CLOCK_CONTROL, in aspeed_adc_probe()
204 17, 15, 0, &data->clk_lock); in aspeed_adc_probe()
205 if (IS_ERR(data->clk_prescaler)) in aspeed_adc_probe()
206 return PTR_ERR(data->clk_prescaler); in aspeed_adc_probe()
209 * Register ADC clock scaler downstream from the prescaler. Allow rate in aspeed_adc_probe()
212 data->clk_scaler = clk_hw_register_divider( in aspeed_adc_probe()
213 &pdev->dev, "scaler", "prescaler", in aspeed_adc_probe()
215 data->base + ASPEED_REG_CLOCK_CONTROL, in aspeed_adc_probe()
216 0, 10, 0, &data->clk_lock); in aspeed_adc_probe()
217 if (IS_ERR(data->clk_scaler)) { in aspeed_adc_probe()
218 ret = PTR_ERR(data->clk_scaler); in aspeed_adc_probe()
222 data->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); in aspeed_adc_probe()
223 if (IS_ERR(data->rst)) { in aspeed_adc_probe()
224 dev_err(&pdev->dev, in aspeed_adc_probe()
226 ret = PTR_ERR(data->rst); in aspeed_adc_probe()
229 reset_control_deassert(data->rst); in aspeed_adc_probe()
231 model_data = of_device_get_match_data(&pdev->dev); in aspeed_adc_probe()
233 if (model_data->wait_init_sequence) { in aspeed_adc_probe()
236 data->base + ASPEED_REG_ENGINE_CONTROL); in aspeed_adc_probe()
239 ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL, in aspeed_adc_probe()
250 ret = clk_prepare_enable(data->clk_scaler->clk); in aspeed_adc_probe()
257 data->base + ASPEED_REG_ENGINE_CONTROL); in aspeed_adc_probe()
259 model_data = of_device_get_match_data(&pdev->dev); in aspeed_adc_probe()
260 indio_dev->name = model_data->model_name; in aspeed_adc_probe()
261 indio_dev->dev.parent = &pdev->dev; in aspeed_adc_probe()
262 indio_dev->info = &aspeed_adc_iio_info; in aspeed_adc_probe()
263 indio_dev->modes = INDIO_DIRECT_MODE; in aspeed_adc_probe()
264 indio_dev->channels = aspeed_adc_iio_channels; in aspeed_adc_probe()
265 indio_dev->num_channels = ARRAY_SIZE(aspeed_adc_iio_channels); in aspeed_adc_probe()
275 data->base + ASPEED_REG_ENGINE_CONTROL); in aspeed_adc_probe()
276 clk_disable_unprepare(data->clk_scaler->clk); in aspeed_adc_probe()
279 reset_control_assert(data->rst); in aspeed_adc_probe()
281 clk_hw_unregister_divider(data->clk_scaler); in aspeed_adc_probe()
283 clk_hw_unregister_divider(data->clk_prescaler); in aspeed_adc_probe()
294 data->base + ASPEED_REG_ENGINE_CONTROL); in aspeed_adc_remove()
295 clk_disable_unprepare(data->clk_scaler->clk); in aspeed_adc_remove()
296 reset_control_assert(data->rst); in aspeed_adc_remove()
297 clk_hw_unregister_divider(data->clk_scaler); in aspeed_adc_remove()
298 clk_hw_unregister_divider(data->clk_prescaler); in aspeed_adc_remove()
304 .model_name = "ast2400-adc",
311 .model_name = "ast2500-adc",
319 { .compatible = "aspeed,ast2400-adc", .data = &ast2400_model_data },
320 { .compatible = "aspeed,ast2500-adc", .data = &ast2500_model_data },
337 MODULE_DESCRIPTION("Aspeed AST2400/2500 ADC Driver");