* [PATCH] ARM: mach-shmobile: sh7372 A3RV power domain prototype
@ 2011-06-24 5:54 Magnus Damm
2011-06-24 6:07 ` Magnus Damm
0 siblings, 1 reply; 2+ messages in thread
From: Magnus Damm @ 2011-06-24 5:54 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@opensource.se>
This somewhat messy prototype patch adds A3RV power domain
control support for sh7372. The A3RV power domain contains
the VPU video encoder/decoder which is exported through UIO.
The prototype serves as an example of a simple power domain
that needs to be turned off during boot. The default setting
after hardware reset is to keep A3RV powered on. The UIO driver
uio_pdrv_genirq.c does not access the VPU hardware at ->probe()
time but instead relies 100% on user space. So the VPU device
and A3RV will always be unused during boot.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Applies to suspend-2.6.git pm-domains as of a few days ago:
commit 6232eb8f755b0eb1a47f6fd6277da879248aba5e
Author: Rafael J. Wysocki <rjw@sisk.pl>
Date: Wed Jun 22 02:20:43 2011 +0200
ARM / shmobile: Support for I/O power domains for SH7372 (v7)
arch/arm/mach-shmobile/board-mackerel.c | 1 -
arch/arm/mach-shmobile/include/mach/sh7372.h | 3 +++
arch/arm/mach-shmobile/pm-sh7372.c | 4 ++++
arch/arm/mach-shmobile/setup-sh7372.c | 5 +++++
4 files changed, 12 insertions(+), 1 deletion(-)
--- 0001/arch/arm/mach-shmobile/board-mackerel.c
+++ work/arch/arm/mach-shmobile/board-mackerel.c 2011-06-22 21:19:13.000000000 +0900
@@ -1582,7 +1582,6 @@ static void __init mackerel_init(void)
platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
- sh7372_init_pm_domain(&sh7372_a4lc_domain);
sh7372_add_device_to_domain(SH7372_A4LC, &lcdc_device);
sh7372_add_device_to_domain(SH7372_A4LC, &hdmi_lcdc_device);
--- 0001/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ work/arch/arm/mach-shmobile/include/mach/sh7372.h 2011-06-22 21:18:26.000000000 +0900
@@ -485,13 +485,16 @@ static inline struct sh7372_pm_domain *t
#ifdef CONFIG_PM
extern struct sh7372_pm_domain sh7372_a4lc_domain;
+extern struct sh7372_pm_domain sh7372_a3rv_domain;
#define SH7372_A4LC (&sh7372_a4lc_domain)
+#define SH7372_A3RV (&sh7372_a3rv_domain)
extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
extern void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
struct platform_device *pdev);
#else
#define SH7372_A4LC NULL
+#define SH7372_A3RV NULL
static inline void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd) {}
static inline void sh7372_add_device_to_domain(struct sh7372_pm_domain *pd,
--- 0001/arch/arm/mach-shmobile/pm-sh7372.c
+++ work/arch/arm/mach-shmobile/pm-sh7372.c 2011-06-22 21:30:44.000000000 +0900
@@ -117,6 +117,10 @@ struct sh7372_pm_domain sh7372_a4lc_doma
.bit_shift = 1,
};
+struct sh7372_pm_domain sh7372_a3rv_domain = {
+ .bit_shift = 6,
+};
+
static void sh7372_enter_core_standby(void)
{
void __iomem *smfram = (void __iomem *)SMFRAM;
--- 0001/arch/arm/mach-shmobile/setup-sh7372.c
+++ work/arch/arm/mach-shmobile/setup-sh7372.c 2011-06-22 21:24:03.000000000 +0900
@@ -841,11 +841,16 @@ static struct platform_device *sh7372_la
void __init sh7372_add_standard_devices(void)
{
+ sh7372_init_pm_domain(SH7372_A4LC);
+ sh7372_init_pm_domain(SH7372_A3RV);
+
platform_add_devices(sh7372_early_devices,
ARRAY_SIZE(sh7372_early_devices));
platform_add_devices(sh7372_late_devices,
ARRAY_SIZE(sh7372_late_devices));
+
+ sh7372_add_device_to_domain(SH7372_A3RV, &vpu_device);
}
void __init sh7372_add_early_devices(void)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM: mach-shmobile: sh7372 A3RV power domain prototype
2011-06-24 5:54 [PATCH] ARM: mach-shmobile: sh7372 A3RV power domain prototype Magnus Damm
@ 2011-06-24 6:07 ` Magnus Damm
0 siblings, 0 replies; 2+ messages in thread
From: Magnus Damm @ 2011-06-24 6:07 UTC (permalink / raw)
To: linux-sh
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
On Fri, Jun 24, 2011 at 3:02 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@opensource.se>
>
> This somewhat messy prototype patch adds A3RV power domain
> control support for sh7372. The A3RV power domain contains
> the VPU video encoder/decoder which is exported through UIO.
>
> The prototype serves as an example of a simple power domain
> that needs to be turned off during boot. The default setting
> after hardware reset is to keep A3RV powered on. The UIO driver
> uio_pdrv_genirq.c does not access the VPU hardware at ->probe()
> time but instead relies 100% on user space. So the VPU device
> and A3RV will always be unused during boot.
Also, people may want to use the attached test program to give this a go.
Without this patch, when "vpu-test" is executed twice then the second
run will produce this message:
"VPU5HG state kept since last open"
The message above is outputted when the state of a certain VPU
register is kept over UIO close->open.
With this patch applied the state of the VPU is always lost between
the UIO close->open, so the above message will never appear - at least
until there is a governor in place that prevents the power from being
turned off based on QoS information.
Cheers,
/ magnus
[-- Attachment #2: vpu-test-20110622.c --]
[-- Type: text/x-csrc, Size: 4223 bytes --]
/*
* vpu-test - AP4 VPU test program, 20110622 Magnus Damm
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
static int fgets_with_openclose(char *fname, char *buf, size_t maxlen) {
FILE *fp;
if ((fp = fopen(fname, "r")) != NULL) {
fgets(buf, maxlen, fp);
fclose(fp);
return strlen(buf);
} else {
return -1;
}
}
struct uio_device {
char *name;
char *path;
int fd;
};
#define MAXUIOIDS 100
#define MAXNAMELEN 256
static int locate_uio_device(char *name, struct uio_device *udp)
{
char fname[MAXNAMELEN], buf[MAXNAMELEN];
int uio_id, i;
for (uio_id = 0; uio_id < MAXUIOIDS; uio_id++) {
sprintf(fname, "/sys/class/uio/uio%d/name", uio_id);
if (fgets_with_openclose(fname, buf, MAXNAMELEN) < 0)
continue;
if (strncmp(name, buf, strlen(name)) == 0)
break;
}
if (uio_id >= MAXUIOIDS)
return -1;
udp->name = strdup(buf);
udp->path = strdup(fname);
udp->path[strlen(udp->path) - 4] = '\0';
sprintf(buf, "/dev/uio%d", uio_id);
udp->fd = open(buf, O_RDWR|O_SYNC /*| O_NONBLOCK*/);
if (udp->fd < 0) {
perror("open");
return -1;
}
return 0;
}
struct uio_map {
unsigned long address;
unsigned long size;
void *iomem;
};
static int setup_uio_map(struct uio_device *udp, int nr, struct uio_map *ump)
{
char fname[MAXNAMELEN], buf[MAXNAMELEN];
sprintf(fname, "%s/maps/map%d/addr", udp->path, nr);
if (fgets_with_openclose(fname, buf, MAXNAMELEN) <= 0)
return -1;
ump->address = strtoul(buf, NULL, 0);
sprintf(fname, "%s/maps/map%d/size", udp->path, nr);
if (fgets_with_openclose(fname, buf, MAXNAMELEN) <= 0)
return -1;
ump->size = strtoul(buf, NULL, 0);
ump->iomem = mmap(0, ump->size,
PROT_READ|PROT_WRITE, MAP_SHARED,
udp->fd, nr * getpagesize());
if (ump->iomem == MAP_FAILED)
return -1;
return 0;
}
struct uio_device uio_dev;
struct uio_map uio_mmio;
int main(int argc, char *argv[])
{
int ret;
ret = locate_uio_device("VPU5HG", &uio_dev);
if (ret < 0) {
fprintf(stderr, "unable to locate UIO device\n");
return 1;
}
ret = setup_uio_map(&uio_dev, 0, &uio_mmio);
if (ret < 0) {
fprintf(stderr, "unable to setup UIO memory map\n");
return 1;
}
{
unsigned long *ph = (uio_mmio.iomem + 0x00); /* VCRH */
unsigned long *pl = (uio_mmio.iomem + 0x04); /* VCRL */
unsigned long *pc = (uio_mmio.iomem + 0x08); /* CMD */
unsigned long *pm = (uio_mmio.iomem + 0x80); /* MBA */
int k;
if ((*ph & 0xffff) == 0x55f4) {
printf("detected VPU5HG with VCRH:VCRL 0x%08lx:%08lx\n",
*ph, *pl);
if (*pm == 0xdeadbeef) {
printf("VPU5HG state kept since last open\n");
}
*pc = 1 << 10; /* set MRST bit to force reset */
for (k = 0; k < 5; k++) {
if (!(*pc & (1 << 10))) {
printf("VPU5HG reset check OK\n");
*pm = 0xdeadbeef;
printf("Sleeping 5 seconds...\n");
sleep(5);
return 0;
}
sleep(1);
}
}
}
fprintf(stderr, "unable to detect/reset VPU5HG\n");
return 1;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-24 6:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 5:54 [PATCH] ARM: mach-shmobile: sh7372 A3RV power domain prototype Magnus Damm
2011-06-24 6:07 ` Magnus Damm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox