Skip to content

Commit 1ec371b

Browse files
fthainalexandrebelloni
authored andcommitted
m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
Both mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones. Tested-by: Daniel Palmer <daniel@0x0f.com> Signed-off-by: Finn Thain <fthain@linux-m68k.org> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://lore.kernel.org/r/19a16bcc94c42ea9c5397b37b1918c2937e3faab.1731450735.git.fthain@linux-m68k.org Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 5b42ede commit 1ec371b

File tree

9 files changed

+54
-264
lines changed

9 files changed

+54
-264
lines changed

arch/m68k/configs/multi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ CONFIG_UHID=m
503503
# CONFIG_USB_SUPPORT is not set
504504
CONFIG_RTC_CLASS=y
505505
# CONFIG_RTC_NVMEM is not set
506+
CONFIG_RTC_DRV_M48T59=m
506507
CONFIG_RTC_DRV_MSM6242=m
507508
CONFIG_RTC_DRV_RP5C01=m
508509
CONFIG_RTC_DRV_GENERIC=m

arch/m68k/configs/mvme147_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ CONFIG_UHID=m
391391
# CONFIG_USB_SUPPORT is not set
392392
CONFIG_RTC_CLASS=y
393393
# CONFIG_RTC_NVMEM is not set
394+
CONFIG_RTC_DRV_M48T59=y
394395
CONFIG_RTC_DRV_GENERIC=m
395396
# CONFIG_VIRTIO_MENU is not set
396397
# CONFIG_VHOST_MENU is not set

arch/m68k/configs/mvme16x_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ CONFIG_UHID=m
392392
# CONFIG_USB_SUPPORT is not set
393393
CONFIG_RTC_CLASS=y
394394
# CONFIG_RTC_NVMEM is not set
395+
CONFIG_RTC_DRV_M48T59=y
395396
CONFIG_RTC_DRV_GENERIC=m
396397
# CONFIG_VIRTIO_MENU is not set
397398
# CONFIG_VHOST_MENU is not set

arch/m68k/include/asm/mvme147hw.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,7 @@
44

55
#include <asm/irq.h>
66

7-
typedef struct {
8-
unsigned char
9-
ctrl,
10-
bcd_sec,
11-
bcd_min,
12-
bcd_hr,
13-
bcd_dow,
14-
bcd_dom,
15-
bcd_mth,
16-
bcd_year;
17-
} MK48T02;
18-
19-
#define RTC_WRITE 0x80
20-
#define RTC_READ 0x40
21-
#define RTC_STOP 0x20
22-
23-
#define m147_rtc ((MK48T02 * volatile)0xfffe07f8)
24-
7+
#define MVME147_RTC_BASE 0xfffe0000
258

269
struct pcc_regs {
2710
volatile u_long dma_tadr;

arch/m68k/include/asm/mvme16xhw.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,7 @@ typedef struct {
2424

2525
#define mvmelp ((*(volatile MVMElpPtr)(MVME_LPR_BASE)))
2626

27-
typedef struct {
28-
unsigned char
29-
ctrl,
30-
bcd_sec,
31-
bcd_min,
32-
bcd_hr,
33-
bcd_dow,
34-
bcd_dom,
35-
bcd_mth,
36-
bcd_year;
37-
} MK48T08_t, *MK48T08ptr_t;
38-
39-
#define RTC_WRITE 0x80
40-
#define RTC_READ 0x40
41-
#define RTC_STOP 0x20
42-
43-
#define MVME_RTC_BASE 0xfffc1ff8
27+
#define MVME_RTC_BASE 0xfffc0000
4428

4529
#define MVME_I596_BASE 0xfff46000
4630

arch/m68k/mvme147/config.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <linux/linkage.h>
2020
#include <linux/init.h>
2121
#include <linux/major.h>
22-
#include <linux/rtc.h>
2322
#include <linux/interrupt.h>
23+
#include <linux/platform_device.h>
24+
#include <linux/rtc/m48t59.h>
2425

2526
#include <asm/bootinfo.h>
2627
#include <asm/bootinfo-vme.h>
@@ -35,13 +36,9 @@
3536

3637
static void mvme147_get_model(char *model);
3738
extern void mvme147_sched_init(void);
38-
extern int mvme147_hwclk (int, struct rtc_time *);
3939
extern void mvme147_reset (void);
4040

4141

42-
static int bcd2int (unsigned char b);
43-
44-
4542
int __init mvme147_parse_bootinfo(const struct bi_record *bi)
4643
{
4744
uint16_t tag = be16_to_cpu(bi->tag);
@@ -79,7 +76,6 @@ void __init config_mvme147(void)
7976
{
8077
mach_sched_init = mvme147_sched_init;
8178
mach_init_IRQ = mvme147_init_IRQ;
82-
mach_hwclk = mvme147_hwclk;
8379
mach_reset = mvme147_reset;
8480
mach_get_model = mvme147_get_model;
8581

@@ -88,6 +84,28 @@ void __init config_mvme147(void)
8884
vme_brdtype = VME_TYPE_MVME147;
8985
}
9086

87+
static struct resource m48t59_rsrc[] = {
88+
DEFINE_RES_MEM(MVME147_RTC_BASE, 0x800),
89+
};
90+
91+
static struct m48t59_plat_data m48t59_data = {
92+
.type = M48T59RTC_TYPE_M48T02,
93+
.yy_offset = 70,
94+
};
95+
96+
static int __init mvme147_platform_init(void)
97+
{
98+
if (!MACH_IS_MVME147)
99+
return 0;
100+
101+
platform_device_register_resndata(NULL, "rtc-m48t59", -1,
102+
m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc),
103+
&m48t59_data, sizeof(m48t59_data));
104+
return 0;
105+
}
106+
107+
arch_initcall(mvme147_platform_init);
108+
91109
static u64 mvme147_read_clk(struct clocksource *cs);
92110

93111
static struct clocksource mvme147_clk = {
@@ -161,27 +179,3 @@ static u64 mvme147_read_clk(struct clocksource *cs)
161179
return ticks;
162180
}
163181

164-
static int bcd2int (unsigned char b)
165-
{
166-
return ((b>>4)*10 + (b&15));
167-
}
168-
169-
int mvme147_hwclk(int op, struct rtc_time *t)
170-
{
171-
if (!op) {
172-
m147_rtc->ctrl = RTC_READ;
173-
t->tm_year = bcd2int (m147_rtc->bcd_year);
174-
t->tm_mon = bcd2int(m147_rtc->bcd_mth) - 1;
175-
t->tm_mday = bcd2int (m147_rtc->bcd_dom);
176-
t->tm_hour = bcd2int (m147_rtc->bcd_hr);
177-
t->tm_min = bcd2int (m147_rtc->bcd_min);
178-
t->tm_sec = bcd2int (m147_rtc->bcd_sec);
179-
m147_rtc->ctrl = 0;
180-
if (t->tm_year < 70)
181-
t->tm_year += 100;
182-
} else {
183-
/* FIXME Setting the time is not yet supported */
184-
return -EOPNOTSUPP;
185-
}
186-
return 0;
187-
}

arch/m68k/mvme16x/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Makefile for Linux arch/m68k/mvme16x source directory
44
#
55

6-
obj-y := config.o rtc.o
6+
obj-y := config.o

arch/m68k/mvme16x/config.c

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#include <linux/linkage.h>
2222
#include <linux/init.h>
2323
#include <linux/major.h>
24-
#include <linux/rtc.h>
2524
#include <linux/interrupt.h>
2625
#include <linux/module.h>
26+
#include <linux/platform_device.h>
27+
#include <linux/rtc/m48t59.h>
2728

2829
#include <asm/bootinfo.h>
2930
#include <asm/bootinfo-vme.h>
@@ -39,16 +40,10 @@
3940

4041
extern t_bdid mvme_bdid;
4142

42-
static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE;
43-
4443
static void mvme16x_get_model(char *model);
4544
extern void mvme16x_sched_init(void);
46-
extern int mvme16x_hwclk (int, struct rtc_time *);
4745
extern void mvme16x_reset (void);
4846

49-
int bcd2int (unsigned char b);
50-
51-
5247
unsigned short mvme16x_config;
5348
EXPORT_SYMBOL(mvme16x_config);
5449

@@ -268,7 +263,6 @@ void __init config_mvme16x(void)
268263

269264
mach_sched_init = mvme16x_sched_init;
270265
mach_init_IRQ = mvme16x_init_IRQ;
271-
mach_hwclk = mvme16x_hwclk;
272266
mach_reset = mvme16x_reset;
273267
mach_get_model = mvme16x_get_model;
274268
mach_get_hardware_list = mvme16x_get_hardware_list;
@@ -312,6 +306,28 @@ void __init config_mvme16x(void)
312306
}
313307
}
314308

309+
static struct resource m48t59_rsrc[] = {
310+
DEFINE_RES_MEM(MVME_RTC_BASE, 0x2000),
311+
};
312+
313+
static struct m48t59_plat_data m48t59_data = {
314+
.type = M48T59RTC_TYPE_M48T08,
315+
.yy_offset = 70,
316+
};
317+
318+
static int __init mvme16x_platform_init(void)
319+
{
320+
if (!MACH_IS_MVME16x)
321+
return 0;
322+
323+
platform_device_register_resndata(NULL, "rtc-m48t59", -1,
324+
m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc),
325+
&m48t59_data, sizeof(m48t59_data));
326+
return 0;
327+
}
328+
329+
arch_initcall(mvme16x_platform_init);
330+
315331
static irqreturn_t mvme16x_abort_int (int irq, void *dev_id)
316332
{
317333
unsigned long *new = (unsigned long *)vectors;
@@ -426,28 +442,3 @@ static u64 mvme16x_read_clk(struct clocksource *cs)
426442

427443
return ticks;
428444
}
429-
430-
int bcd2int (unsigned char b)
431-
{
432-
return ((b>>4)*10 + (b&15));
433-
}
434-
435-
int mvme16x_hwclk(int op, struct rtc_time *t)
436-
{
437-
if (!op) {
438-
rtc->ctrl = RTC_READ;
439-
t->tm_year = bcd2int (rtc->bcd_year);
440-
t->tm_mon = bcd2int(rtc->bcd_mth) - 1;
441-
t->tm_mday = bcd2int (rtc->bcd_dom);
442-
t->tm_hour = bcd2int (rtc->bcd_hr);
443-
t->tm_min = bcd2int (rtc->bcd_min);
444-
t->tm_sec = bcd2int (rtc->bcd_sec);
445-
rtc->ctrl = 0;
446-
if (t->tm_year < 70)
447-
t->tm_year += 100;
448-
} else {
449-
/* FIXME Setting the time is not yet supported */
450-
return -EOPNOTSUPP;
451-
}
452-
return 0;
453-
}

0 commit comments

Comments
 (0)