Commit aff05ed5 authored by Linus Walleij's avatar Linus Walleij Committed by Linus Torvalds

rtc: pl031: encapsulate per-vendor ops

Move the per-vendor operations for this RTC into a encapsulating struct so
we can have more per-vendor variables than just the ops.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 36ac1d24
...@@ -68,7 +68,16 @@ ...@@ -68,7 +68,16 @@
#define RTC_TIMER_FREQ 32768 #define RTC_TIMER_FREQ 32768
/**
* struct pl031_vendor_data - per-vendor variations
* @ops: the vendor-specific operations used on this silicon version
*/
struct pl031_vendor_data {
struct rtc_class_ops ops;
};
struct pl031_local { struct pl031_local {
struct pl031_vendor_data *vendor;
struct rtc_device *rtc; struct rtc_device *rtc;
void __iomem *base; void __iomem *base;
u8 hw_designer; u8 hw_designer;
...@@ -303,7 +312,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -303,7 +312,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
{ {
int ret; int ret;
struct pl031_local *ldata; struct pl031_local *ldata;
struct rtc_class_ops *ops = id->data; struct pl031_vendor_data *vendor = id->data;
struct rtc_class_ops *ops = &vendor->ops;
unsigned long time; unsigned long time;
ret = amba_request_regions(adev, NULL); ret = amba_request_regions(adev, NULL);
...@@ -315,6 +325,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -315,6 +325,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
ldata->vendor = vendor;
ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
...@@ -383,48 +394,54 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -383,48 +394,54 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
} }
/* Operations for the original ARM version */ /* Operations for the original ARM version */
static struct rtc_class_ops arm_pl031_ops = { static struct pl031_vendor_data arm_pl031 = {
.ops = {
.read_time = pl031_read_time, .read_time = pl031_read_time,
.set_time = pl031_set_time, .set_time = pl031_set_time,
.read_alarm = pl031_read_alarm, .read_alarm = pl031_read_alarm,
.set_alarm = pl031_set_alarm, .set_alarm = pl031_set_alarm,
.alarm_irq_enable = pl031_alarm_irq_enable, .alarm_irq_enable = pl031_alarm_irq_enable,
},
}; };
/* The First ST derivative */ /* The First ST derivative */
static struct rtc_class_ops stv1_pl031_ops = { static struct pl031_vendor_data stv1_pl031 = {
.ops = {
.read_time = pl031_read_time, .read_time = pl031_read_time,
.set_time = pl031_set_time, .set_time = pl031_set_time,
.read_alarm = pl031_read_alarm, .read_alarm = pl031_read_alarm,
.set_alarm = pl031_set_alarm, .set_alarm = pl031_set_alarm,
.alarm_irq_enable = pl031_alarm_irq_enable, .alarm_irq_enable = pl031_alarm_irq_enable,
},
}; };
/* And the second ST derivative */ /* And the second ST derivative */
static struct rtc_class_ops stv2_pl031_ops = { static struct pl031_vendor_data stv2_pl031 = {
.ops = {
.read_time = pl031_stv2_read_time, .read_time = pl031_stv2_read_time,
.set_time = pl031_stv2_set_time, .set_time = pl031_stv2_set_time,
.read_alarm = pl031_stv2_read_alarm, .read_alarm = pl031_stv2_read_alarm,
.set_alarm = pl031_stv2_set_alarm, .set_alarm = pl031_stv2_set_alarm,
.alarm_irq_enable = pl031_alarm_irq_enable, .alarm_irq_enable = pl031_alarm_irq_enable,
},
}; };
static struct amba_id pl031_ids[] = { static struct amba_id pl031_ids[] = {
{ {
.id = 0x00041031, .id = 0x00041031,
.mask = 0x000fffff, .mask = 0x000fffff,
.data = &arm_pl031_ops, .data = &arm_pl031,
}, },
/* ST Micro variants */ /* ST Micro variants */
{ {
.id = 0x00180031, .id = 0x00180031,
.mask = 0x00ffffff, .mask = 0x00ffffff,
.data = &stv1_pl031_ops, .data = &stv1_pl031,
}, },
{ {
.id = 0x00280031, .id = 0x00280031,
.mask = 0x00ffffff, .mask = 0x00ffffff,
.data = &stv2_pl031_ops, .data = &stv2_pl031,
}, },
{0, 0}, {0, 0},
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment