Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3af8b49 authored by Jean-Christophe PLAGNIOL-VILLARD's avatar Jean-Christophe PLAGNIOL-VILLARD Committed by Nicolas Ferre
Browse files

ARM: at91/rtc-at91sam9: pass the GPBR to use via resources



The GPBR registers are used for storing RTC values. The GPBR registers
to use are now provided using standard resource entry. The array is
filled in SoC specific code.
rtc-at91sam9 RTT as RTC driver is modified to retrieve this information.

Signed-off-by: default avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
[nicolas.ferre@atmel.com: rework resources assignment]
Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Reviewed-by: default avatarRyan Mallon <rmallon@gmail.com>
parent 4e9267f1
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -718,14 +718,15 @@ static struct resource rtt_resources[] = {
		.start	= AT91SAM9260_BASE_RTT,
		.end	= AT91SAM9260_BASE_RTT + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}
	}, {
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device at91sam9260_rtt_device = {
	.name		= "at91_rtt",
	.id		= 0,
	.resource	= rtt_resources,
	.num_resources	= ARRAY_SIZE(rtt_resources),
};


@@ -733,9 +734,21 @@ static struct platform_device at91sam9260_rtt_device = {
static void __init at91_add_device_rtt_rtc(void)
{
	at91sam9260_rtt_device.name = "rtc-at91sam9";
	/*
	 * The second resource is needed:
	 * GPBR will serve as the storage for RTC time offset
	 */
	at91sam9260_rtt_device.num_resources = 2;
	rtt_resources[1].start = AT91SAM9260_BASE_GPBR +
				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
	rtt_resources[1].end = rtt_resources[1].start + 3;
}
#else
static void __init at91_add_device_rtt_rtc(void) {}
static void __init at91_add_device_rtt_rtc(void)
{
	/* Only one resource is needed: RTT not used as RTC */
	at91sam9260_rtt_device.num_resources = 1;
}
#endif

static void __init at91_add_device_rtt(void)
+15 −2
Original line number Diff line number Diff line
@@ -604,6 +604,8 @@ static struct resource rtt_resources[] = {
		.start	= AT91SAM9261_BASE_RTT,
		.end	= AT91SAM9261_BASE_RTT + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}, {
		.flags	= IORESOURCE_MEM,
	}
};

@@ -611,16 +613,27 @@ static struct platform_device at91sam9261_rtt_device = {
	.name		= "at91_rtt",
	.id		= 0,
	.resource	= rtt_resources,
	.num_resources	= ARRAY_SIZE(rtt_resources),
};

#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
static void __init at91_add_device_rtt_rtc(void)
{
	at91sam9261_rtt_device.name = "rtc-at91sam9";
	/*
	 * The second resource is needed:
	 * GPBR will serve as the storage for RTC time offset
	 */
	at91sam9261_rtt_device.num_resources = 2;
	rtt_resources[1].start = AT91SAM9261_BASE_GPBR +
				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
	rtt_resources[1].end = rtt_resources[1].start + 3;
}
#else
static void __init at91_add_device_rtt_rtc(void) {}
static void __init at91_add_device_rtt_rtc(void)
{
	/* Only one resource is needed: RTT not used as RTC */
	at91sam9261_rtt_device.num_resources = 1;
}
#endif

static void __init at91_add_device_rtt(void)
+25 −5
Original line number Diff line number Diff line
@@ -967,6 +967,8 @@ static struct resource rtt0_resources[] = {
		.start	= AT91SAM9263_BASE_RTT0,
		.end	= AT91SAM9263_BASE_RTT0 + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}, {
		.flags	= IORESOURCE_MEM,
	}
};

@@ -974,7 +976,6 @@ static struct platform_device at91sam9263_rtt0_device = {
	.name		= "at91_rtt",
	.id		= 0,
	.resource	= rtt0_resources,
	.num_resources	= ARRAY_SIZE(rtt0_resources),
};

static struct resource rtt1_resources[] = {
@@ -982,6 +983,8 @@ static struct resource rtt1_resources[] = {
		.start	= AT91SAM9263_BASE_RTT1,
		.end	= AT91SAM9263_BASE_RTT1 + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}, {
		.flags	= IORESOURCE_MEM,
	}
};

@@ -989,31 +992,48 @@ static struct platform_device at91sam9263_rtt1_device = {
	.name		= "at91_rtt",
	.id		= 1,
	.resource	= rtt1_resources,
	.num_resources	= ARRAY_SIZE(rtt1_resources),
};

#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
static void __init at91_add_device_rtt_rtc(void)
{
	struct platform_device *pdev;
	struct resource *r;

	switch (CONFIG_RTC_DRV_AT91SAM9_RTT) {
	case 0:
		/*
		 * The second resource is needed only for the chosen RTT:
		 * GPBR will serve as the storage for RTC time offset
		 */
		at91sam9263_rtt0_device.num_resources = 2;
		at91sam9263_rtt1_device.num_resources = 1;
		pdev = &at91sam9263_rtt0_device;
		r = rtt0_resources;
		break;
	case 1:
		at91sam9263_rtt0_device.num_resources = 1;
		at91sam9263_rtt1_device.num_resources = 2;
		pdev = &at91sam9263_rtt1_device;
		r = rtt1_resources;
		break;
	default:
		pr_err("at91sam9263: support only 2 RTT (%d)\n",
		pr_err("at91sam9263: only supports 2 RTT (%d)\n",
		       CONFIG_RTC_DRV_AT91SAM9_RTT);
		return;
	}

	pdev->name = "rtc-at91sam9";
	r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
	r[1].end = r[1].start + 3;
}
#else
static void __init at91_add_device_rtt_rtc(void) {}
static void __init at91_add_device_rtt_rtc(void)
{
	/* Only one resource is needed: RTT not used as RTC */
	at91sam9263_rtt0_device.num_resources = 1;
	at91sam9263_rtt1_device.num_resources = 1;
}
#endif

static void __init at91_add_device_rtt(void)
+15 −2
Original line number Diff line number Diff line
@@ -1194,6 +1194,8 @@ static struct resource rtt_resources[] = {
		.start	= AT91SAM9G45_BASE_RTT,
		.end	= AT91SAM9G45_BASE_RTT + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}, {
		.flags	= IORESOURCE_MEM,
	}
};

@@ -1201,16 +1203,27 @@ static struct platform_device at91sam9g45_rtt_device = {
	.name		= "at91_rtt",
	.id		= 0,
	.resource	= rtt_resources,
	.num_resources	= ARRAY_SIZE(rtt_resources),
};

#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
static void __init at91_add_device_rtt_rtc(void)
{
	at91sam9g45_rtt_device.name = "rtc-at91sam9";
	/*
	 * The second resource is needed:
	 * GPBR will serve as the storage for RTC time offset
	 */
	at91sam9g45_rtt_device.num_resources = 2;
	rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
	rtt_resources[1].end = rtt_resources[1].start + 3;
}
#else
static void __init at91_add_device_rtt_rtc(void) {}
static void __init at91_add_device_rtt_rtc(void)
{
	/* Only one resource is needed: RTT not used as RTC */
	at91sam9g45_rtt_device.num_resources = 1;
}
#endif

static void __init at91_add_device_rtt(void)
+15 −2
Original line number Diff line number Diff line
@@ -683,6 +683,8 @@ static struct resource rtt_resources[] = {
		.start	= AT91SAM9RL_BASE_RTT,
		.end	= AT91SAM9RL_BASE_RTT + SZ_16 - 1,
		.flags	= IORESOURCE_MEM,
	}, {
		.flags	= IORESOURCE_MEM,
	}
};

@@ -690,16 +692,27 @@ static struct platform_device at91sam9rl_rtt_device = {
	.name		= "at91_rtt",
	.id		= 0,
	.resource	= rtt_resources,
	.num_resources	= ARRAY_SIZE(rtt_resources),
};

#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
static void __init at91_add_device_rtt_rtc(void)
{
	at91sam9rl_rtt_device.name = "rtc-at91sam9";
	/*
	 * The second resource is needed:
	 * GPBR will serve as the storage for RTC time offset
	 */
	at91sam9rl_rtt_device.num_resources = 2;
	rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
	rtt_resources[1].end = rtt_resources[1].start + 3;
}
#else
static void __init at91_add_device_rtt_rtc(void) {}
static void __init at91_add_device_rtt_rtc(void)
{
	/* Only one resource is needed: RTT not used as RTC */
	at91sam9rl_rtt_device.num_resources = 1;
}
#endif

static void __init at91_add_device_rtt(void)
Loading