@@ -136,6 +136,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)
return -EINVAL;
}
+ tscadc->data = of_device_get_match_data(&pdev->dev);
+
node = of_get_child_by_name(pdev->dev.of_node, "tsc");
of_property_read_u32(node, "ti,wires", &tsc_wires);
of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
@@ -209,7 +211,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
goto err_disable_clk;
}
- tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
+ tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
/* Set the control register bits */
@@ -238,8 +240,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)
if (tsc_wires > 0) {
tscadc->tsc_cell = tscadc->used_cells;
cell = &tscadc->cells[tscadc->used_cells++];
- cell->name = "TI-am335x-tsc";
- cell->of_compatible = "ti,am3359-tsc";
+ cell->name = tscadc->data->name_tscmag;
+ cell->of_compatible = tscadc->data->compat_tscmag;
cell->platform_data = &tscadc;
cell->pdata_size = sizeof(tscadc);
}
@@ -248,8 +250,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)
if (adc_channels > 0) {
tscadc->adc_cell = tscadc->used_cells;
cell = &tscadc->cells[tscadc->used_cells++];
- cell->name = "TI-am335x-adc";
- cell->of_compatible = "ti,am3359-adc";
+ cell->name = tscadc->data->name_adc;
+ cell->of_compatible = tscadc->data->compat_adc;
cell->platform_data = &tscadc;
cell->pdata_size = sizeof(tscadc);
}
@@ -335,6 +337,14 @@ static int __maybe_unused tscadc_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
+static const struct ti_tscadc_data tscdata = {
+ .name_tscmag = "TI-am335x-tsc",
+ .compat_tscmag = "ti,am3359-tsc",
+ .name_adc = "TI-am335x-adc",
+ .compat_adc = "ti,am3359-adc",
+ .target_clk_rate = ADC_CLK,
+};
+
static const struct of_device_id ti_tscadc_dt_ids[] = {
{ .compatible = "ti,am3359-tscadc", },
{ }
@@ -162,11 +162,20 @@
#define TSCADC_CELLS 2
+struct ti_tscadc_data {
+ char *name_tscmag;
+ char *compat_tscmag;
+ char *name_adc;
+ char *compat_adc;
+ unsigned int target_clk_rate;
+};
+
struct ti_tscadc_dev {
struct device *dev;
struct regmap *regmap;
void __iomem *tscadc_base;
phys_addr_t tscadc_phys_base;
+ const struct ti_tscadc_data *data;
int irq;
int used_cells; /* 1-2 */
int tsc_wires;