mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge
This commit is contained in:
commit
6150c32589
287 changed files with 27018 additions and 5874 deletions
|
|
@ -149,14 +149,14 @@ config MAC_EMUMOUSEBTN
|
|||
|
||||
config THERM_WINDTUNNEL
|
||||
tristate "Support for thermal management on Windtunnel G4s"
|
||||
depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64
|
||||
depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
|
||||
help
|
||||
This driver provides some thermostat and fan control for the desktop
|
||||
G4 "Windtunnel"
|
||||
|
||||
config THERM_ADT746X
|
||||
tristate "Support for thermal mgmnt on laptops with ADT 746x chipset"
|
||||
depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64
|
||||
depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
|
||||
help
|
||||
This driver provides some thermostat and fan control for the
|
||||
iBook G4, and the ATI based aluminium PowerBooks, allowing slighlty
|
||||
|
|
@ -164,7 +164,7 @@ config THERM_ADT746X
|
|||
|
||||
config THERM_PM72
|
||||
tristate "Support for thermal management on PowerMac G5"
|
||||
depends on I2C && I2C_KEYWEST && PPC_PMAC64
|
||||
depends on I2C && I2C_POWERMAC && PPC_PMAC64
|
||||
help
|
||||
This driver provides thermostat and fan control for the desktop
|
||||
G5 machines.
|
||||
|
|
@ -175,14 +175,14 @@ config WINDFARM
|
|||
config WINDFARM_PM81
|
||||
tristate "Support for thermal management on iMac G5"
|
||||
depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
|
||||
select I2C_PMAC_SMU
|
||||
select I2C_POWERMAC
|
||||
help
|
||||
This driver provides thermal control for the iMacG5
|
||||
|
||||
config WINDFARM_PM91
|
||||
tristate "Support for thermal management on PowerMac9,1"
|
||||
depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
|
||||
select I2C_PMAC_SMU
|
||||
select I2C_POWERMAC
|
||||
help
|
||||
This driver provides thermal control for the PowerMac9,1
|
||||
which is the recent (SMU based) single CPU desktop G5
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
* a MacIO ASIC. Interface to new driver model mostly
|
||||
* stolen from the PCI version.
|
||||
*
|
||||
* Copyright (C) 2005 Ben. Herrenschmidt (benh@kernel.crashing.org)
|
||||
*
|
||||
* 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; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* - Don't probe below media bay by default, but instead provide
|
||||
|
|
@ -218,12 +225,14 @@ postcore_initcall(macio_bus_driver_init);
|
|||
|
||||
|
||||
/**
|
||||
* macio_release_dev - free a macio device structure when all users of it are finished.
|
||||
* macio_release_dev - free a macio device structure when all users of it are
|
||||
* finished.
|
||||
* @dev: device that's been disconnected
|
||||
*
|
||||
* Will be called only by the device core when all users of this macio device are
|
||||
* done. This currently means never as we don't hot remove any macio device yet,
|
||||
* though that will happen with mediabay based devices in a later implementation.
|
||||
* Will be called only by the device core when all users of this macio device
|
||||
* are done. This currently means never as we don't hot remove any macio
|
||||
* device yet, though that will happen with mediabay based devices in a later
|
||||
* implementation.
|
||||
*/
|
||||
static void macio_release_dev(struct device *dev)
|
||||
{
|
||||
|
|
@ -242,49 +251,114 @@ static void macio_release_dev(struct device *dev)
|
|||
* If this routine returns non-null, then the resource is completely
|
||||
* skipped.
|
||||
*/
|
||||
static int macio_resource_quirks(struct device_node *np, struct resource *res, int index)
|
||||
static int macio_resource_quirks(struct device_node *np, struct resource *res,
|
||||
int index)
|
||||
{
|
||||
if (res->flags & IORESOURCE_MEM) {
|
||||
/* Grand Central has too large resource 0 on some machines */
|
||||
if (index == 0 && !strcmp(np->name, "gc")) {
|
||||
np->addrs[0].size = 0x20000;
|
||||
if (index == 0 && !strcmp(np->name, "gc"))
|
||||
res->end = res->start + 0x1ffff;
|
||||
}
|
||||
|
||||
/* Airport has bogus resource 2 */
|
||||
if (index >= 2 && !strcmp(np->name, "radio"))
|
||||
return 1;
|
||||
|
||||
#ifndef CONFIG_PPC64
|
||||
/* DBDMAs may have bogus sizes */
|
||||
if ((res->start & 0x0001f000) == 0x00008000) {
|
||||
np->addrs[index].size = 0x100;
|
||||
if ((res->start & 0x0001f000) == 0x00008000)
|
||||
res->end = res->start + 0xff;
|
||||
}
|
||||
/* ESCC parent eats child resources. We could have added a level of hierarchy,
|
||||
* but I don't really feel the need for it */
|
||||
#endif /* CONFIG_PPC64 */
|
||||
|
||||
/* ESCC parent eats child resources. We could have added a
|
||||
* level of hierarchy, but I don't really feel the need
|
||||
* for it
|
||||
*/
|
||||
if (!strcmp(np->name, "escc"))
|
||||
return 1;
|
||||
|
||||
/* ESCC has bogus resources >= 3 */
|
||||
if (index >= 3 && !(strcmp(np->name, "ch-a") && strcmp(np->name, "ch-b")))
|
||||
if (index >= 3 && !(strcmp(np->name, "ch-a") &&
|
||||
strcmp(np->name, "ch-b")))
|
||||
return 1;
|
||||
|
||||
/* Media bay has too many resources, keep only first one */
|
||||
if (index > 0 && !strcmp(np->name, "media-bay"))
|
||||
return 1;
|
||||
|
||||
/* Some older IDE resources have bogus sizes */
|
||||
if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") &&
|
||||
strcmp(np->type, "ide") && strcmp(np->type, "ata"))) {
|
||||
if (index == 0 && np->addrs[0].size > 0x1000) {
|
||||
np->addrs[0].size = 0x1000;
|
||||
if (index == 0 && (res->end - res->start) > 0xfff)
|
||||
res->end = res->start + 0xfff;
|
||||
}
|
||||
if (index == 1 && np->addrs[1].size > 0x100) {
|
||||
np->addrs[1].size = 0x100;
|
||||
if (index == 1 && (res->end - res->start) > 0xff)
|
||||
res->end = res->start + 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void macio_setup_interrupts(struct macio_dev *dev)
|
||||
{
|
||||
struct device_node *np = dev->ofdev.node;
|
||||
int i,j;
|
||||
|
||||
/* For now, we use pre-parsed entries in the device-tree for
|
||||
* interrupt routing and addresses, but we should change that
|
||||
* to dynamically parsed entries and so get rid of most of the
|
||||
* clutter in struct device_node
|
||||
*/
|
||||
for (i = j = 0; i < np->n_intrs; i++) {
|
||||
struct resource *res = &dev->interrupt[j];
|
||||
|
||||
if (j >= MACIO_DEV_COUNT_IRQS)
|
||||
break;
|
||||
res->start = np->intrs[i].line;
|
||||
res->flags = IORESOURCE_IO;
|
||||
if (np->intrs[j].sense)
|
||||
res->flags |= IORESOURCE_IRQ_LOWLEVEL;
|
||||
else
|
||||
res->flags |= IORESOURCE_IRQ_HIGHEDGE;
|
||||
res->name = dev->ofdev.dev.bus_id;
|
||||
if (macio_resource_quirks(np, res, i))
|
||||
memset(res, 0, sizeof(struct resource));
|
||||
else
|
||||
j++;
|
||||
}
|
||||
dev->n_interrupts = j;
|
||||
}
|
||||
|
||||
static void macio_setup_resources(struct macio_dev *dev,
|
||||
struct resource *parent_res)
|
||||
{
|
||||
struct device_node *np = dev->ofdev.node;
|
||||
struct resource r;
|
||||
int index;
|
||||
|
||||
for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) {
|
||||
struct resource *res = &dev->resource[index];
|
||||
if (index >= MACIO_DEV_COUNT_RESOURCES)
|
||||
break;
|
||||
*res = r;
|
||||
res->name = dev->ofdev.dev.bus_id;
|
||||
|
||||
if (macio_resource_quirks(np, res, index)) {
|
||||
memset(res, 0, sizeof(struct resource));
|
||||
continue;
|
||||
}
|
||||
/* Currently, we consider failure as harmless, this may
|
||||
* change in the future, once I've found all the device
|
||||
* tree bugs in older machines & worked around them
|
||||
*/
|
||||
if (insert_resource(parent_res, res)) {
|
||||
printk(KERN_WARNING "Can't request resource "
|
||||
"%d for MacIO device %s\n",
|
||||
index, dev->ofdev.dev.bus_id);
|
||||
}
|
||||
}
|
||||
dev->n_resources = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* macio_add_one_device - Add one device from OF node to the device tree
|
||||
* @chip: pointer to the macio_chip holding the device
|
||||
|
|
@ -294,12 +368,13 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, i
|
|||
* When media-bay is changed to hotswap drivers, this function will
|
||||
* be exposed to the bay driver some way...
|
||||
*/
|
||||
static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent,
|
||||
struct device_node *np, struct macio_dev *in_bay,
|
||||
static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
|
||||
struct device *parent,
|
||||
struct device_node *np,
|
||||
struct macio_dev *in_bay,
|
||||
struct resource *parent_res)
|
||||
{
|
||||
struct macio_dev *dev;
|
||||
int i, j;
|
||||
u32 *reg;
|
||||
|
||||
if (np == NULL)
|
||||
|
|
@ -326,7 +401,8 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct d
|
|||
|
||||
/* MacIO itself has a different reg, we use it's PCI base */
|
||||
if (np == chip->of_node) {
|
||||
sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", chip->lbus.index,
|
||||
sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s",
|
||||
chip->lbus.index,
|
||||
#ifdef CONFIG_PCI
|
||||
pci_resource_start(chip->lbus.pdev, 0),
|
||||
#else
|
||||
|
|
@ -335,57 +411,16 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct d
|
|||
MAX_NODE_NAME_SIZE, np->name);
|
||||
} else {
|
||||
reg = (u32 *)get_property(np, "reg", NULL);
|
||||
sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", chip->lbus.index,
|
||||
sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s",
|
||||
chip->lbus.index,
|
||||
reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name);
|
||||
}
|
||||
|
||||
/* For now, we use pre-parsed entries in the device-tree for
|
||||
* interrupt routing and addresses, but we should change that
|
||||
* to dynamically parsed entries and so get rid of most of the
|
||||
* clutter in struct device_node
|
||||
*/
|
||||
for (i = j = 0; i < np->n_intrs; i++) {
|
||||
struct resource *res = &dev->interrupt[j];
|
||||
|
||||
if (j >= MACIO_DEV_COUNT_IRQS)
|
||||
break;
|
||||
res->start = np->intrs[i].line;
|
||||
res->flags = IORESOURCE_IO;
|
||||
if (np->intrs[j].sense)
|
||||
res->flags |= IORESOURCE_IRQ_LOWLEVEL;
|
||||
else
|
||||
res->flags |= IORESOURCE_IRQ_HIGHEDGE;
|
||||
res->name = dev->ofdev.dev.bus_id;
|
||||
if (macio_resource_quirks(np, res, i))
|
||||
memset(res, 0, sizeof(struct resource));
|
||||
else
|
||||
j++;
|
||||
}
|
||||
dev->n_interrupts = j;
|
||||
for (i = j = 0; i < np->n_addrs; i++) {
|
||||
struct resource *res = &dev->resource[j];
|
||||
|
||||
if (j >= MACIO_DEV_COUNT_RESOURCES)
|
||||
break;
|
||||
res->start = np->addrs[i].address;
|
||||
res->end = np->addrs[i].address + np->addrs[i].size - 1;
|
||||
res->flags = IORESOURCE_MEM;
|
||||
res->name = dev->ofdev.dev.bus_id;
|
||||
if (macio_resource_quirks(np, res, i))
|
||||
memset(res, 0, sizeof(struct resource));
|
||||
else {
|
||||
j++;
|
||||
/* Currently, we consider failure as harmless, this may
|
||||
* change in the future, once I've found all the device
|
||||
* tree bugs in older machines & worked around them
|
||||
*/
|
||||
if (insert_resource(parent_res, res))
|
||||
printk(KERN_WARNING "Can't request resource %d for MacIO"
|
||||
" device %s\n", i, dev->ofdev.dev.bus_id);
|
||||
}
|
||||
}
|
||||
dev->n_resources = j;
|
||||
/* Setup interrupts & resources */
|
||||
macio_setup_interrupts(dev);
|
||||
macio_setup_resources(dev, parent_res);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&dev->ofdev) != 0) {
|
||||
printk(KERN_DEBUG"macio: device registration error for %s!\n",
|
||||
dev->ofdev.dev.bus_id);
|
||||
|
|
@ -442,36 +477,42 @@ static void macio_pci_add_devices(struct macio_chip *chip)
|
|||
|
||||
/* First scan 1st level */
|
||||
for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
|
||||
if (!macio_skip_device(np)) {
|
||||
of_node_get(np);
|
||||
mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL, root_res);
|
||||
if (mdev == NULL)
|
||||
of_node_put(np);
|
||||
else if (strncmp(np->name, "media-bay", 9) == 0)
|
||||
mbdev = mdev;
|
||||
else if (strncmp(np->name, "escc", 4) == 0)
|
||||
sdev = mdev;
|
||||
}
|
||||
if (macio_skip_device(np))
|
||||
continue;
|
||||
of_node_get(np);
|
||||
mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL,
|
||||
root_res);
|
||||
if (mdev == NULL)
|
||||
of_node_put(np);
|
||||
else if (strncmp(np->name, "media-bay", 9) == 0)
|
||||
mbdev = mdev;
|
||||
else if (strncmp(np->name, "escc", 4) == 0)
|
||||
sdev = mdev;
|
||||
}
|
||||
|
||||
/* Add media bay devices if any */
|
||||
if (mbdev)
|
||||
for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;)
|
||||
if (!macio_skip_device(np)) {
|
||||
of_node_get(np);
|
||||
if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev,
|
||||
root_res) == NULL)
|
||||
of_node_put(np);
|
||||
}
|
||||
for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np))
|
||||
!= NULL;) {
|
||||
if (macio_skip_device(np))
|
||||
continue;
|
||||
of_node_get(np);
|
||||
if (macio_add_one_device(chip, &mbdev->ofdev.dev, np,
|
||||
mbdev, root_res) == NULL)
|
||||
of_node_put(np);
|
||||
}
|
||||
|
||||
/* Add serial ports if any */
|
||||
if (sdev) {
|
||||
for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;)
|
||||
if (!macio_skip_device(np)) {
|
||||
of_node_get(np);
|
||||
if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL,
|
||||
root_res) == NULL)
|
||||
of_node_put(np);
|
||||
}
|
||||
for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np))
|
||||
!= NULL;) {
|
||||
if (macio_skip_device(np))
|
||||
continue;
|
||||
of_node_get(np);
|
||||
if (macio_add_one_device(chip, &sdev->ofdev.dev, np,
|
||||
NULL, root_res) == NULL)
|
||||
of_node_put(np);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -519,7 +560,8 @@ void macio_unregister_driver(struct macio_driver *drv)
|
|||
* Returns 0 on success, or %EBUSY on error. A warning
|
||||
* message is also printed on failure.
|
||||
*/
|
||||
int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name)
|
||||
int macio_request_resource(struct macio_dev *dev, int resource_no,
|
||||
const char *name)
|
||||
{
|
||||
if (macio_resource_len(dev, resource_no) == 0)
|
||||
return 0;
|
||||
|
|
@ -606,20 +648,20 @@ static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_devi
|
|||
if (ent->vendor != PCI_VENDOR_ID_APPLE)
|
||||
return -ENODEV;
|
||||
|
||||
/* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
|
||||
* to new OF APIs and returns a node with refcount incremented. This isn't
|
||||
* the case today, but on the other hand ppc32 doesn't do refcounting. This
|
||||
* will have to be fixed when going to ppc64. --BenH.
|
||||
/* Note regarding refcounting: We assume pci_device_to_OF_node() is
|
||||
* ported to new OF APIs and returns a node with refcount incremented.
|
||||
*/
|
||||
np = pci_device_to_OF_node(pdev);
|
||||
if (np == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
/* This assumption is wrong, fix that here for now until I fix the arch */
|
||||
/* The above assumption is wrong !!!
|
||||
* fix that here for now until I fix the arch code
|
||||
*/
|
||||
of_node_get(np);
|
||||
|
||||
/* We also assume that pmac_feature will have done a get() on nodes stored
|
||||
* in the macio chips array
|
||||
/* We also assume that pmac_feature will have done a get() on nodes
|
||||
* stored in the macio chips array
|
||||
*/
|
||||
chip = macio_find(np, macio_unknown);
|
||||
of_node_put(np);
|
||||
|
|
@ -639,9 +681,9 @@ static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_devi
|
|||
|
||||
/*
|
||||
* HACK ALERT: The WallStreet PowerBook and some OHare based machines
|
||||
* have 2 macio ASICs. I must probe the "main" one first or IDE ordering
|
||||
* will be incorrect. So I put on "hold" the second one since it seem to
|
||||
* appear first on PCI
|
||||
* have 2 macio ASICs. I must probe the "main" one first or IDE
|
||||
* ordering will be incorrect. So I put on "hold" the second one since
|
||||
* it seem to appear first on PCI
|
||||
*/
|
||||
if (chip->type == macio_gatwick || chip->type == macio_ohareII)
|
||||
if (macio_chips[0].lbus.pdev == NULL) {
|
||||
|
|
|
|||
|
|
@ -647,6 +647,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de
|
|||
struct media_bay_info* bay;
|
||||
u32 __iomem *regbase;
|
||||
struct device_node *ofnode;
|
||||
unsigned long base;
|
||||
int i;
|
||||
|
||||
ofnode = mdev->ofdev.node;
|
||||
|
|
@ -656,10 +657,11 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de
|
|||
if (macio_request_resources(mdev, "media-bay"))
|
||||
return -EBUSY;
|
||||
/* Media bay registers are located at the beginning of the
|
||||
* mac-io chip, we get the parent address for now (hrm...)
|
||||
* mac-io chip, for now, we trick and align down the first
|
||||
* resource passed in
|
||||
*/
|
||||
regbase = (u32 __iomem *)
|
||||
ioremap(ofnode->parent->addrs[0].address, 0x100);
|
||||
base = macio_resource_start(mdev, 0) & 0xffff0000u;
|
||||
regbase = (u32 __iomem *)ioremap(base, 0x100);
|
||||
if (regbase == NULL) {
|
||||
macio_release_resources(mdev);
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
#undef DEBUG_SMU
|
||||
|
||||
#ifdef DEBUG_SMU
|
||||
#define DPRINTK(fmt, args...) do { udbg_printf(KERN_DEBUG fmt , ##args); } while (0)
|
||||
#define DPRINTK(fmt, args...) do { printk(KERN_DEBUG fmt , ##args); } while (0)
|
||||
#else
|
||||
#define DPRINTK(fmt, args...) do { } while (0)
|
||||
#endif
|
||||
|
|
@ -94,6 +94,8 @@ struct smu_device {
|
|||
static struct smu_device *smu;
|
||||
static DECLARE_MUTEX(smu_part_access);
|
||||
|
||||
static void smu_i2c_retry(unsigned long data);
|
||||
|
||||
/*
|
||||
* SMU driver low level stuff
|
||||
*/
|
||||
|
|
@ -469,7 +471,6 @@ int __init smu_init (void)
|
|||
smu->of_node = np;
|
||||
smu->db_irq = NO_IRQ;
|
||||
smu->msg_irq = NO_IRQ;
|
||||
init_timer(&smu->i2c_timer);
|
||||
|
||||
/* smu_cmdbuf_abs is in the low 2G of RAM, can be converted to a
|
||||
* 32 bits value safely
|
||||
|
|
@ -544,6 +545,10 @@ static int smu_late_init(void)
|
|||
if (!smu)
|
||||
return 0;
|
||||
|
||||
init_timer(&smu->i2c_timer);
|
||||
smu->i2c_timer.function = smu_i2c_retry;
|
||||
smu->i2c_timer.data = (unsigned long)smu;
|
||||
|
||||
/*
|
||||
* Try to request the interrupts
|
||||
*/
|
||||
|
|
@ -570,7 +575,10 @@ static int smu_late_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
arch_initcall(smu_late_init);
|
||||
/* This has to be before arch_initcall as the low i2c stuff relies on the
|
||||
* above having been done before we reach arch_initcalls
|
||||
*/
|
||||
core_initcall(smu_late_init);
|
||||
|
||||
/*
|
||||
* sysfs visibility
|
||||
|
|
@ -580,20 +588,10 @@ static void smu_expose_childs(void *unused)
|
|||
{
|
||||
struct device_node *np;
|
||||
|
||||
for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) {
|
||||
if (device_is_compatible(np, "smu-i2c")) {
|
||||
char name[32];
|
||||
u32 *reg = (u32 *)get_property(np, "reg", NULL);
|
||||
|
||||
if (reg == NULL)
|
||||
continue;
|
||||
sprintf(name, "smu-i2c-%02x", *reg);
|
||||
of_platform_device_create(np, name, &smu->of_dev->dev);
|
||||
}
|
||||
for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
|
||||
if (device_is_compatible(np, "smu-sensors"))
|
||||
of_platform_device_create(np, "smu-sensors", &smu->of_dev->dev);
|
||||
}
|
||||
|
||||
of_platform_device_create(np, "smu-sensors",
|
||||
&smu->of_dev->dev);
|
||||
}
|
||||
|
||||
static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL);
|
||||
|
|
@ -712,13 +710,13 @@ static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail)
|
|||
|
||||
static void smu_i2c_retry(unsigned long data)
|
||||
{
|
||||
struct smu_i2c_cmd *cmd = (struct smu_i2c_cmd *)data;
|
||||
struct smu_i2c_cmd *cmd = smu->cmd_i2c_cur;
|
||||
|
||||
DPRINTK("SMU: i2c failure, requeuing...\n");
|
||||
|
||||
/* requeue command simply by resetting reply_len */
|
||||
cmd->pdata[0] = 0xff;
|
||||
cmd->scmd.reply_len = 0x10;
|
||||
cmd->scmd.reply_len = sizeof(cmd->pdata);
|
||||
smu_queue_cmd(&cmd->scmd);
|
||||
}
|
||||
|
||||
|
|
@ -747,10 +745,8 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
|
|||
*/
|
||||
if (fail && --cmd->retries > 0) {
|
||||
DPRINTK("SMU: i2c failure, starting timer...\n");
|
||||
smu->i2c_timer.function = smu_i2c_retry;
|
||||
smu->i2c_timer.data = (unsigned long)cmd;
|
||||
smu->i2c_timer.expires = jiffies + msecs_to_jiffies(5);
|
||||
add_timer(&smu->i2c_timer);
|
||||
BUG_ON(cmd != smu->cmd_i2c_cur);
|
||||
mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -764,7 +760,7 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
|
|||
|
||||
/* Ok, initial command complete, now poll status */
|
||||
scmd->reply_buf = cmd->pdata;
|
||||
scmd->reply_len = 0x10;
|
||||
scmd->reply_len = sizeof(cmd->pdata);
|
||||
scmd->data_buf = cmd->pdata;
|
||||
scmd->data_len = 1;
|
||||
cmd->pdata[0] = 0;
|
||||
|
|
@ -786,7 +782,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
|
|||
cmd->scmd.done = smu_i2c_low_completion;
|
||||
cmd->scmd.misc = cmd;
|
||||
cmd->scmd.reply_buf = cmd->pdata;
|
||||
cmd->scmd.reply_len = 0x10;
|
||||
cmd->scmd.reply_len = sizeof(cmd->pdata);
|
||||
cmd->scmd.data_buf = (u8 *)(char *)&cmd->info;
|
||||
cmd->scmd.status = 1;
|
||||
cmd->stage = 0;
|
||||
|
|
@ -909,10 +905,13 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
|
|||
struct property *prop;
|
||||
|
||||
/* First query the partition info */
|
||||
DPRINTK("SMU: Query partition infos ... (irq=%d)\n", smu->db_irq);
|
||||
smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2,
|
||||
smu_done_complete, &comp,
|
||||
SMU_CMD_PARTITION_LATEST, id);
|
||||
wait_for_completion(&comp);
|
||||
DPRINTK("SMU: done, status: %d, reply_len: %d\n",
|
||||
cmd.cmd.status, cmd.cmd.reply_len);
|
||||
|
||||
/* Partition doesn't exist (or other error) */
|
||||
if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6)
|
||||
|
|
@ -975,6 +974,8 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
|
|||
|
||||
sprintf(pname, "sdb-partition-%02x", id);
|
||||
|
||||
DPRINTK("smu_get_sdb_partition(%02x)\n", id);
|
||||
|
||||
if (interruptible) {
|
||||
int rc;
|
||||
rc = down_interruptible(&smu_part_access);
|
||||
|
|
@ -986,6 +987,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
|
|||
part = (struct smu_sdbp_header *)get_property(smu->of_node,
|
||||
pname, size);
|
||||
if (part == NULL) {
|
||||
DPRINTK("trying to extract from SMU ...\n");
|
||||
part = smu_create_sdb_partition(id);
|
||||
if (part != NULL && size)
|
||||
*size = part->len << 2;
|
||||
|
|
|
|||
|
|
@ -127,39 +127,34 @@ struct adb_driver via_cuda_driver = {
|
|||
#endif /* CONFIG_ADB */
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
int __init
|
||||
find_via_cuda(void)
|
||||
int __init find_via_cuda(void)
|
||||
{
|
||||
int err;
|
||||
struct adb_request req;
|
||||
phys_addr_t taddr;
|
||||
u32 *reg;
|
||||
int err;
|
||||
|
||||
if (vias != 0)
|
||||
return 1;
|
||||
vias = find_devices("via-cuda");
|
||||
vias = of_find_node_by_name(NULL, "via-cuda");
|
||||
if (vias == 0)
|
||||
return 0;
|
||||
if (vias->next != 0)
|
||||
printk(KERN_WARNING "Warning: only using 1st via-cuda\n");
|
||||
|
||||
#if 0
|
||||
{ int i;
|
||||
|
||||
printk("find_via_cuda: node = %p, addrs =", vias->node);
|
||||
for (i = 0; i < vias->n_addrs; ++i)
|
||||
printk(" %x(%x)", vias->addrs[i].address, vias->addrs[i].size);
|
||||
printk(", intrs =");
|
||||
for (i = 0; i < vias->n_intrs; ++i)
|
||||
printk(" %x", vias->intrs[i].line);
|
||||
printk("\n"); }
|
||||
#endif
|
||||
|
||||
if (vias->n_addrs != 1 || vias->n_intrs != 1) {
|
||||
printk(KERN_ERR "via-cuda: expecting 1 address (%d) and 1 interrupt (%d)\n",
|
||||
vias->n_addrs, vias->n_intrs);
|
||||
if (vias->n_addrs < 1 || vias->n_intrs < 1)
|
||||
return 0;
|
||||
reg = (u32 *)get_property(vias, "reg", NULL);
|
||||
if (reg == NULL) {
|
||||
printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
|
||||
goto fail;
|
||||
}
|
||||
taddr = of_translate_address(vias, reg);
|
||||
if (taddr == 0) {
|
||||
printk(KERN_ERR "via-cuda: Can't translate address !\n");
|
||||
goto fail;
|
||||
}
|
||||
via = ioremap(taddr, 0x2000);
|
||||
if (via == NULL) {
|
||||
printk(KERN_ERR "via-cuda: Can't map address !\n");
|
||||
goto fail;
|
||||
}
|
||||
via = ioremap(vias->addrs->address, 0x2000);
|
||||
|
||||
cuda_state = idle;
|
||||
sys_ctrler = SYS_CTRLER_CUDA;
|
||||
|
|
@ -185,6 +180,11 @@ find_via_cuda(void)
|
|||
cuda_poll();
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
of_node_put(vias);
|
||||
vias = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PPC */
|
||||
|
||||
|
|
@ -193,10 +193,6 @@ static int __init via_cuda_start(void)
|
|||
if (via == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
request_OF_resource(vias, 0, NULL);
|
||||
#endif
|
||||
|
||||
if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
|
||||
printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ);
|
||||
return -EAGAIN;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
#include <asm/sections.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/pmac_feature.h>
|
||||
#include <asm/pmac_pfunc.h>
|
||||
#include <asm/pmac_low_i2c.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/mmu_context.h>
|
||||
#include <asm/cputable.h>
|
||||
|
|
@ -147,6 +149,7 @@ static struct device_node *vias;
|
|||
static int pmu_kind = PMU_UNKNOWN;
|
||||
static int pmu_fully_inited = 0;
|
||||
static int pmu_has_adb;
|
||||
static struct device_node *gpio_node;
|
||||
static unsigned char __iomem *gpio_reg = NULL;
|
||||
static int gpio_irq = -1;
|
||||
static int gpio_irq_enabled = -1;
|
||||
|
|
@ -157,8 +160,8 @@ static int pmu_version;
|
|||
static int drop_interrupts;
|
||||
#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
|
||||
static int option_lid_wakeup = 1;
|
||||
static int sleep_in_progress;
|
||||
#endif /* CONFIG_PM && CONFIG_PPC32 */
|
||||
static int sleep_in_progress;
|
||||
static unsigned long async_req_locks;
|
||||
static unsigned int pmu_irq_stats[11];
|
||||
|
||||
|
|
@ -196,7 +199,6 @@ static int pmu_adb_reset_bus(void);
|
|||
#endif /* CONFIG_ADB */
|
||||
|
||||
static int init_pmu(void);
|
||||
static int pmu_queue_request(struct adb_request *req);
|
||||
static void pmu_start(void);
|
||||
static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs);
|
||||
static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
|
||||
|
|
@ -295,22 +297,26 @@ static struct backlight_controller pmu_backlight_controller = {
|
|||
};
|
||||
#endif /* CONFIG_PMAC_BACKLIGHT */
|
||||
|
||||
int
|
||||
find_via_pmu(void)
|
||||
int __init find_via_pmu(void)
|
||||
{
|
||||
u64 taddr;
|
||||
u32 *reg;
|
||||
|
||||
if (via != 0)
|
||||
return 1;
|
||||
vias = find_devices("via-pmu");
|
||||
if (vias == 0)
|
||||
vias = of_find_node_by_name(NULL, "via-pmu");
|
||||
if (vias == NULL)
|
||||
return 0;
|
||||
if (vias->next != 0)
|
||||
printk(KERN_WARNING "Warning: only using 1st via-pmu\n");
|
||||
|
||||
if (vias->n_addrs < 1 || vias->n_intrs < 1) {
|
||||
printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n",
|
||||
vias->n_addrs, vias->n_intrs);
|
||||
if (vias->n_addrs < 1 || vias->n_intrs < 1)
|
||||
return 0;
|
||||
reg = (u32 *)get_property(vias, "reg", NULL);
|
||||
if (reg == NULL) {
|
||||
printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
|
||||
goto fail;
|
||||
}
|
||||
taddr = of_translate_address(vias, reg);
|
||||
if (taddr == OF_BAD_ADDR) {
|
||||
printk(KERN_ERR "via-pmu: Can't translate address !\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
spin_lock_init(&pmu_lock);
|
||||
|
|
@ -331,7 +337,8 @@ find_via_pmu(void)
|
|||
pmu_kind = PMU_HEATHROW_BASED;
|
||||
else if (device_is_compatible(vias->parent, "Keylargo")
|
||||
|| device_is_compatible(vias->parent, "K2-Keylargo")) {
|
||||
struct device_node *gpio, *gpiop;
|
||||
struct device_node *gpiop;
|
||||
u64 gaddr = OF_BAD_ADDR;
|
||||
|
||||
pmu_kind = PMU_KEYLARGO_BASED;
|
||||
pmu_has_adb = (find_type_devices("adb") != NULL);
|
||||
|
|
@ -341,19 +348,24 @@ find_via_pmu(void)
|
|||
PMU_INT_TICK |
|
||||
PMU_INT_ENVIRONMENT;
|
||||
|
||||
gpiop = find_devices("gpio");
|
||||
if (gpiop && gpiop->n_addrs) {
|
||||
gpio_reg = ioremap(gpiop->addrs->address, 0x10);
|
||||
gpio = find_devices("extint-gpio1");
|
||||
if (gpio == NULL)
|
||||
gpio = find_devices("pmu-interrupt");
|
||||
if (gpio && gpio->parent == gpiop && gpio->n_intrs)
|
||||
gpio_irq = gpio->intrs[0].line;
|
||||
gpiop = of_find_node_by_name(NULL, "gpio");
|
||||
if (gpiop) {
|
||||
reg = (u32 *)get_property(gpiop, "reg", NULL);
|
||||
if (reg)
|
||||
gaddr = of_translate_address(gpiop, reg);
|
||||
if (gaddr != OF_BAD_ADDR)
|
||||
gpio_reg = ioremap(gaddr, 0x10);
|
||||
}
|
||||
if (gpio_reg == NULL)
|
||||
printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n");
|
||||
} else
|
||||
pmu_kind = PMU_UNKNOWN;
|
||||
|
||||
via = ioremap(vias->addrs->address, 0x2000);
|
||||
via = ioremap(taddr, 0x2000);
|
||||
if (via == NULL) {
|
||||
printk(KERN_ERR "via-pmu: Can't map address !\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */
|
||||
out_8(&via[IFR], 0x7f); /* clear IFR */
|
||||
|
|
@ -365,23 +377,25 @@ find_via_pmu(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "PMU driver %d initialized for %s, firmware: %02x\n",
|
||||
printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n",
|
||||
PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version);
|
||||
|
||||
sys_ctrler = SYS_CTRLER_PMU;
|
||||
|
||||
return 1;
|
||||
fail:
|
||||
of_node_put(vias);
|
||||
vias = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ADB
|
||||
static int
|
||||
pmu_probe(void)
|
||||
static int pmu_probe(void)
|
||||
{
|
||||
return vias == NULL? -ENODEV: 0;
|
||||
}
|
||||
|
||||
static int __init
|
||||
pmu_init(void)
|
||||
static int __init pmu_init(void)
|
||||
{
|
||||
if (vias == NULL)
|
||||
return -ENODEV;
|
||||
|
|
@ -405,7 +419,7 @@ static int __init via_pmu_start(void)
|
|||
bright_req_2.complete = 1;
|
||||
batt_req.complete = 1;
|
||||
|
||||
#if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE)
|
||||
#ifndef CONFIG_PPC_MERGE
|
||||
if (pmu_kind == PMU_KEYLARGO_BASED)
|
||||
openpic_set_irq_priority(vias->intrs[0].line,
|
||||
OPENPIC_PRIORITY_DEFAULT + 1);
|
||||
|
|
@ -418,10 +432,22 @@ static int __init via_pmu_start(void)
|
|||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
|
||||
if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1 ADB", (void *)0))
|
||||
printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
|
||||
gpio_irq_enabled = 1;
|
||||
if (pmu_kind == PMU_KEYLARGO_BASED) {
|
||||
gpio_node = of_find_node_by_name(NULL, "extint-gpio1");
|
||||
if (gpio_node == NULL)
|
||||
gpio_node = of_find_node_by_name(NULL,
|
||||
"pmu-interrupt");
|
||||
if (gpio_node && gpio_node->n_intrs > 0)
|
||||
gpio_irq = gpio_node->intrs[0].line;
|
||||
|
||||
if (gpio_irq != -1) {
|
||||
if (request_irq(gpio_irq, gpio1_interrupt, 0,
|
||||
"GPIO1 ADB", (void *)0))
|
||||
printk(KERN_ERR "pmu: can't get irq %d"
|
||||
" (GPIO1)\n", gpio_irq);
|
||||
else
|
||||
gpio_irq_enabled = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable interrupts */
|
||||
|
|
@ -454,9 +480,6 @@ static int __init via_pmu_dev_init(void)
|
|||
if (vias == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
#ifndef CONFIG_PPC64
|
||||
request_OF_resource(vias, 0, NULL);
|
||||
#endif
|
||||
#ifdef CONFIG_PMAC_BACKLIGHT
|
||||
/* Enable backlight */
|
||||
register_backlight_controller(&pmu_backlight_controller, NULL, "pmu");
|
||||
|
|
@ -1371,7 +1394,6 @@ next:
|
|||
}
|
||||
pmu_done(req);
|
||||
} else {
|
||||
#if defined(CONFIG_XMON) && !defined(CONFIG_PPC64)
|
||||
if (len == 4 && data[1] == 0x2c) {
|
||||
extern int xmon_wants_key, xmon_adb_keycode;
|
||||
if (xmon_wants_key) {
|
||||
|
|
@ -1379,7 +1401,6 @@ next:
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif /* defined(CONFIG_XMON) && !defined(CONFIG_PPC64) */
|
||||
#ifdef CONFIG_ADB
|
||||
/*
|
||||
* XXX On the [23]400 the PMU gives us an up
|
||||
|
|
@ -1782,258 +1803,6 @@ pmu_present(void)
|
|||
return via != 0;
|
||||
}
|
||||
|
||||
struct pmu_i2c_hdr {
|
||||
u8 bus;
|
||||
u8 mode;
|
||||
u8 bus2;
|
||||
u8 address;
|
||||
u8 sub_addr;
|
||||
u8 comb_addr;
|
||||
u8 count;
|
||||
};
|
||||
|
||||
int
|
||||
pmu_i2c_combined_read(int bus, int addr, int subaddr, u8* data, int len)
|
||||
{
|
||||
struct adb_request req;
|
||||
struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1];
|
||||
int retry;
|
||||
int rc;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
hdr->bus = bus;
|
||||
hdr->address = addr & 0xfe;
|
||||
hdr->mode = PMU_I2C_MODE_COMBINED;
|
||||
hdr->bus2 = 0;
|
||||
hdr->sub_addr = subaddr;
|
||||
hdr->comb_addr = addr | 1;
|
||||
hdr->count = len;
|
||||
|
||||
req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
req.reply[0] = 0xff;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
break;
|
||||
mdelay(15);
|
||||
}
|
||||
if (req.reply[0] != PMU_I2C_STATUS_OK)
|
||||
return -1;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
mdelay(15);
|
||||
|
||||
hdr->bus = PMU_I2C_BUS_STATUS;
|
||||
req.reply[0] = 0xff;
|
||||
|
||||
req.nbytes = 2;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
|
||||
memcpy(data, &req.reply[1], req.reply_len - 1);
|
||||
return req.reply_len - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
pmu_i2c_stdsub_write(int bus, int addr, int subaddr, u8* data, int len)
|
||||
{
|
||||
struct adb_request req;
|
||||
struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1];
|
||||
int retry;
|
||||
int rc;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
hdr->bus = bus;
|
||||
hdr->address = addr & 0xfe;
|
||||
hdr->mode = PMU_I2C_MODE_STDSUB;
|
||||
hdr->bus2 = 0;
|
||||
hdr->sub_addr = subaddr;
|
||||
hdr->comb_addr = addr & 0xfe;
|
||||
hdr->count = len;
|
||||
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
|
||||
req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.reply[0] = 0xff;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
break;
|
||||
mdelay(15);
|
||||
}
|
||||
if (req.reply[0] != PMU_I2C_STATUS_OK)
|
||||
return -1;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
mdelay(15);
|
||||
|
||||
hdr->bus = PMU_I2C_BUS_STATUS;
|
||||
req.reply[0] = 0xff;
|
||||
|
||||
req.nbytes = 2;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
return len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
pmu_i2c_simple_read(int bus, int addr, u8* data, int len)
|
||||
{
|
||||
struct adb_request req;
|
||||
struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1];
|
||||
int retry;
|
||||
int rc;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
hdr->bus = bus;
|
||||
hdr->address = addr | 1;
|
||||
hdr->mode = PMU_I2C_MODE_SIMPLE;
|
||||
hdr->bus2 = 0;
|
||||
hdr->sub_addr = 0;
|
||||
hdr->comb_addr = 0;
|
||||
hdr->count = len;
|
||||
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.reply[0] = 0xff;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
break;
|
||||
mdelay(15);
|
||||
}
|
||||
if (req.reply[0] != PMU_I2C_STATUS_OK)
|
||||
return -1;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
mdelay(15);
|
||||
|
||||
hdr->bus = PMU_I2C_BUS_STATUS;
|
||||
req.reply[0] = 0xff;
|
||||
|
||||
req.nbytes = 2;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
|
||||
memcpy(data, &req.reply[1], req.reply_len - 1);
|
||||
return req.reply_len - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
pmu_i2c_simple_write(int bus, int addr, u8* data, int len)
|
||||
{
|
||||
struct adb_request req;
|
||||
struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1];
|
||||
int retry;
|
||||
int rc;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
hdr->bus = bus;
|
||||
hdr->address = addr & 0xfe;
|
||||
hdr->mode = PMU_I2C_MODE_SIMPLE;
|
||||
hdr->bus2 = 0;
|
||||
hdr->sub_addr = 0;
|
||||
hdr->comb_addr = 0;
|
||||
hdr->count = len;
|
||||
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
|
||||
req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.reply[0] = 0xff;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
break;
|
||||
mdelay(15);
|
||||
}
|
||||
if (req.reply[0] != PMU_I2C_STATUS_OK)
|
||||
return -1;
|
||||
|
||||
for (retry=0; retry<16; retry++) {
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
mdelay(15);
|
||||
|
||||
hdr->bus = PMU_I2C_BUS_STATUS;
|
||||
req.reply[0] = 0xff;
|
||||
|
||||
req.nbytes = 2;
|
||||
req.reply_expected = 0;
|
||||
req.reply_len = 0;
|
||||
req.data[0] = PMU_I2C_CMD;
|
||||
rc = pmu_queue_request(&req);
|
||||
if (rc)
|
||||
return rc;
|
||||
while(!req.complete)
|
||||
pmu_poll();
|
||||
if (req.reply[0] == PMU_I2C_STATUS_OK)
|
||||
return len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
||||
static LIST_HEAD(sleep_notifiers);
|
||||
|
|
@ -2338,8 +2107,9 @@ pmac_suspend_devices(void)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Disable clock spreading on some machines */
|
||||
pmac_tweak_clock_spreading(0);
|
||||
/* Call platform functions marked "on sleep" */
|
||||
pmac_pfunc_i2c_suspend();
|
||||
pmac_pfunc_base_suspend();
|
||||
|
||||
/* Stop preemption */
|
||||
preempt_disable();
|
||||
|
|
@ -2411,8 +2181,9 @@ pmac_wakeup_devices(void)
|
|||
mdelay(10);
|
||||
preempt_enable();
|
||||
|
||||
/* Re-enable clock spreading on some machines */
|
||||
pmac_tweak_clock_spreading(1);
|
||||
/* Call platform functions marked "on wake" */
|
||||
pmac_pfunc_base_resume();
|
||||
pmac_pfunc_i2c_resume();
|
||||
|
||||
/* Resume devices */
|
||||
device_resume();
|
||||
|
|
@ -3130,16 +2901,13 @@ static int __init init_pmu_sysfs(void)
|
|||
subsys_initcall(init_pmu_sysfs);
|
||||
|
||||
EXPORT_SYMBOL(pmu_request);
|
||||
EXPORT_SYMBOL(pmu_queue_request);
|
||||
EXPORT_SYMBOL(pmu_poll);
|
||||
EXPORT_SYMBOL(pmu_poll_adb);
|
||||
EXPORT_SYMBOL(pmu_wait_complete);
|
||||
EXPORT_SYMBOL(pmu_suspend);
|
||||
EXPORT_SYMBOL(pmu_resume);
|
||||
EXPORT_SYMBOL(pmu_unlock);
|
||||
EXPORT_SYMBOL(pmu_i2c_combined_read);
|
||||
EXPORT_SYMBOL(pmu_i2c_stdsub_write);
|
||||
EXPORT_SYMBOL(pmu_i2c_simple_read);
|
||||
EXPORT_SYMBOL(pmu_i2c_simple_write);
|
||||
#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
|
||||
EXPORT_SYMBOL(pmu_enable_irled);
|
||||
EXPORT_SYMBOL(pmu_battery_count);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <asm/io.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/sections.h>
|
||||
#include <asm/pmac_low_i2c.h>
|
||||
|
||||
#include "windfarm.h"
|
||||
|
||||
|
|
@ -157,53 +158,21 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
|
|||
|
||||
static int wf_lm75_attach(struct i2c_adapter *adapter)
|
||||
{
|
||||
u8 bus_id;
|
||||
struct device_node *smu, *bus, *dev;
|
||||
|
||||
/* We currently only deal with LM75's hanging off the SMU
|
||||
* i2c busses. If we extend that driver to other/older
|
||||
* machines, we should split this function into SMU-i2c,
|
||||
* keywest-i2c, PMU-i2c, ...
|
||||
*/
|
||||
struct device_node *busnode, *dev;
|
||||
struct pmac_i2c_bus *bus;
|
||||
|
||||
DBG("wf_lm75: adapter %s detected\n", adapter->name);
|
||||
|
||||
if (strncmp(adapter->name, "smu-i2c-", 8) != 0)
|
||||
return 0;
|
||||
smu = of_find_node_by_type(NULL, "smu");
|
||||
if (smu == NULL)
|
||||
return 0;
|
||||
|
||||
/* Look for the bus in the device-tree */
|
||||
bus_id = (u8)simple_strtoul(adapter->name + 8, NULL, 16);
|
||||
|
||||
DBG("wf_lm75: bus ID is %x\n", bus_id);
|
||||
|
||||
/* Look for sensors subdir */
|
||||
for (bus = NULL;
|
||||
(bus = of_get_next_child(smu, bus)) != NULL;) {
|
||||
u32 *reg;
|
||||
|
||||
if (strcmp(bus->name, "i2c"))
|
||||
continue;
|
||||
reg = (u32 *)get_property(bus, "reg", NULL);
|
||||
if (reg == NULL)
|
||||
continue;
|
||||
if (bus_id == *reg)
|
||||
break;
|
||||
}
|
||||
of_node_put(smu);
|
||||
if (bus == NULL) {
|
||||
printk(KERN_WARNING "windfarm: SMU i2c bus 0x%x not found"
|
||||
" in device-tree !\n", bus_id);
|
||||
return 0;
|
||||
}
|
||||
bus = pmac_i2c_adapter_to_bus(adapter);
|
||||
if (bus == NULL)
|
||||
return -ENODEV;
|
||||
busnode = pmac_i2c_get_bus_node(bus);
|
||||
|
||||
DBG("wf_lm75: bus found, looking for device...\n");
|
||||
|
||||
/* Now look for lm75(s) in there */
|
||||
for (dev = NULL;
|
||||
(dev = of_get_next_child(bus, dev)) != NULL;) {
|
||||
(dev = of_get_next_child(busnode, dev)) != NULL;) {
|
||||
const char *loc =
|
||||
get_property(dev, "hwsensor-location", NULL);
|
||||
u32 *reg = (u32 *)get_property(dev, "reg", NULL);
|
||||
|
|
@ -217,9 +186,6 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
|
|||
else if (device_is_compatible(dev, "ds1775"))
|
||||
wf_lm75_create(adapter, *reg, 1, loc);
|
||||
}
|
||||
|
||||
of_node_put(bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue