Skip to content

Commit 64151ad

Browse files
Krzysztof-Hdavem330
authored andcommitted
rtc-m48t59: allow externally mapped ioaddr
Add support for externally mapped ioaddr. This is required on sparc32 as the ioaddr must be mapped with of_ioremap(). Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 94fe742 commit 64151ad

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎drivers/rtc/rtc-m48t59.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,14 @@ static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
411411
if (!m48t59)
412412
return -ENOMEM;
413413

414-
m48t59->ioaddr = ioremap(res->start, res->end - res->start + 1);
415-
if (!m48t59->ioaddr)
416-
goto out;
414+
m48t59->ioaddr = pdata->ioaddr;
415+
416+
if (!m48t59->ioaddr) {
417+
/* ioaddr not mapped externally */
418+
m48t59->ioaddr = ioremap(res->start, res->end - res->start + 1);
419+
if (!m48t59->ioaddr)
420+
goto out;
421+
}
417422

418423
/* Try to get irq number. We also can work in
419424
* the mode without IRQ.
@@ -481,11 +486,12 @@ static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
481486
static int __devexit m48t59_rtc_remove(struct platform_device *pdev)
482487
{
483488
struct m48t59_private *m48t59 = platform_get_drvdata(pdev);
489+
struct m48t59_plat_data *pdata = pdev->dev.platform_data;
484490

485491
sysfs_remove_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
486492
if (!IS_ERR(m48t59->rtc))
487493
rtc_device_unregister(m48t59->rtc);
488-
if (m48t59->ioaddr)
494+
if (m48t59->ioaddr && !pdata->ioaddr)
489495
iounmap(m48t59->ioaddr);
490496
if (m48t59->irq != NO_IRQ)
491497
free_irq(m48t59->irq, &pdev->dev);

‎include/linux/rtc/m48t59.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct m48t59_plat_data {
5555

5656
int type; /* RTC model */
5757

58+
/* ioaddr mapped externally */
59+
void __iomem *ioaddr;
5860
/* offset to RTC registers, automatically set according to the type */
5961
unsigned int offset;
6062
};

0 commit comments

Comments
 (0)