aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powermac/feature.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-01-06 19:30:44 -0500
committerPaul Mackerras <paulus@samba.org>2006-01-08 23:47:16 -0500
commit730745a5c45093982112ddc94cee6a9973455641 (patch)
tree1c36bd96c28d08e2b5d839ba3f4e37588aad2328 /arch/powerpc/platforms/powermac/feature.c
parent002ec58eb57bac2380f0ed5a4e88121b4bdb32ec (diff)
[PATCH] 1/5 powerpc: Rework PowerMac i2c part 1
This is the first part of a rework of the PowerMac i2c code. It completely reworks the "low_i2c" layer. It is now more flexible, supports KeyWest, SMU and PMU i2c busses, and provides functions to match device nodes to i2c busses and adapters. This patch also extends & fix some bugs in the SMU driver related to i2c support and removes the clock spreading hacks from the pmac feature code rather than adapting them to the new API since they'll be replaced by the platform function code completely in patch 3/5 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/powermac/feature.c')
-rw-r--r--arch/powerpc/platforms/powermac/feature.c127
1 files changed, 0 insertions, 127 deletions
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index d2915d64d45..b271b11583a 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1677,124 +1677,6 @@ intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
1677} 1677}
1678 1678
1679 1679
1680void pmac_tweak_clock_spreading(int enable)
1681{
1682 struct macio_chip *macio = &macio_chips[0];
1683
1684 /* Hack for doing clock spreading on some machines PowerBooks and
1685 * iBooks. This implements the "platform-do-clockspreading" OF
1686 * property as decoded manually on various models. For safety, we also
1687 * check the product ID in the device-tree in cases we'll whack the i2c
1688 * chip to make reasonably sure we won't set wrong values in there
1689 *
1690 * Of course, ultimately, we have to implement a real parser for
1691 * the platform-do-* stuff...
1692 */
1693
1694 if (macio->type == macio_intrepid) {
1695 struct device_node *clock =
1696 of_find_node_by_path("/uni-n@f8000000/hw-clock");
1697 if (clock && get_property(clock, "platform-do-clockspreading",
1698 NULL)) {
1699 printk(KERN_INFO "%sabling clock spreading on Intrepid"
1700 " ASIC\n", enable ? "En" : "Dis");
1701 if (enable)
1702 UN_OUT(UNI_N_CLOCK_SPREADING, 2);
1703 else
1704 UN_OUT(UNI_N_CLOCK_SPREADING, 0);
1705 mdelay(40);
1706 }
1707 of_node_put(clock);
1708 }
1709
1710 while (machine_is_compatible("PowerBook5,2") ||
1711 machine_is_compatible("PowerBook5,3") ||
1712 machine_is_compatible("PowerBook6,2") ||
1713 machine_is_compatible("PowerBook6,3")) {
1714 struct device_node *ui2c = of_find_node_by_type(NULL, "i2c");
1715 struct device_node *dt = of_find_node_by_name(NULL, "device-tree");
1716 u8 buffer[9];
1717 u32 *productID;
1718 int i, rc, changed = 0;
1719
1720 if (dt == NULL)
1721 break;
1722 productID = (u32 *)get_property(dt, "pid#", NULL);
1723 if (productID == NULL)
1724 break;
1725 while(ui2c) {
1726 struct device_node *p = of_get_parent(ui2c);
1727 if (p && !strcmp(p->name, "uni-n"))
1728 break;
1729 ui2c = of_find_node_by_type(ui2c, "i2c");
1730 }
1731 if (ui2c == NULL)
1732 break;
1733 DBG("Trying to bump clock speed for PID: %08x...\n", *productID);
1734 rc = pmac_low_i2c_open(ui2c, 1);
1735 if (rc != 0)
1736 break;
1737 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
1738 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
1739 DBG("read result: %d,", rc);
1740 if (rc != 0) {
1741 pmac_low_i2c_close(ui2c);
1742 break;
1743 }
1744 for (i=0; i<9; i++)
1745 DBG(" %02x", buffer[i]);
1746 DBG("\n");
1747
1748 switch(*productID) {
1749 case 0x1182: /* AlBook 12" rev 2 */
1750 case 0x1183: /* iBook G4 12" */
1751 buffer[0] = (buffer[0] & 0x8f) | 0x70;
1752 buffer[2] = (buffer[2] & 0x7f) | 0x00;
1753 buffer[5] = (buffer[5] & 0x80) | 0x31;
1754 buffer[6] = (buffer[6] & 0x40) | 0xb0;
1755 buffer[7] = (buffer[7] & 0x00) | (enable ? 0xc0 : 0xba);
1756 buffer[8] = (buffer[8] & 0x00) | 0x30;
1757 changed = 1;
1758 break;
1759 case 0x3142: /* AlBook 15" (ATI M10) */
1760 case 0x3143: /* AlBook 17" (ATI M10) */
1761 buffer[0] = (buffer[0] & 0xaf) | 0x50;
1762 buffer[2] = (buffer[2] & 0x7f) | 0x00;
1763 buffer[5] = (buffer[5] & 0x80) | 0x31;
1764 buffer[6] = (buffer[6] & 0x40) | 0xb0;
1765 buffer[7] = (buffer[7] & 0x00) | (enable ? 0xd0 : 0xc0);
1766 buffer[8] = (buffer[8] & 0x00) | 0x30;
1767 changed = 1;
1768 break;
1769 default:
1770 DBG("i2c-hwclock: Machine model not handled\n");
1771 break;
1772 }
1773 if (!changed) {
1774 pmac_low_i2c_close(ui2c);
1775 break;
1776 }
1777 printk(KERN_INFO "%sabling clock spreading on i2c clock chip\n",
1778 enable ? "En" : "Dis");
1779
1780 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);
1781 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);
1782 DBG("write result: %d,", rc);
1783 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
1784 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
1785 DBG("read result: %d,", rc);
1786 if (rc != 0) {
1787 pmac_low_i2c_close(ui2c);
1788 break;
1789 }
1790 for (i=0; i<9; i++)
1791 DBG(" %02x", buffer[i]);
1792 pmac_low_i2c_close(ui2c);
1793 break;
1794 }
1795}
1796
1797
1798static int 1680static int
1799core99_sleep(void) 1681core99_sleep(void)
1800{ 1682{
@@ -2980,12 +2862,6 @@ set_initial_features(void)
2980 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N); 2862 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
2981 } 2863 }
2982 2864
2983 /* Some machine models need the clock chip to be properly setup for
2984 * clock spreading now. This should be a platform function but we
2985 * don't do these at the moment
2986 */
2987 pmac_tweak_clock_spreading(1);
2988
2989#endif /* CONFIG_POWER4 */ 2865#endif /* CONFIG_POWER4 */
2990 2866
2991 /* On all machines, switch modem & serial ports off */ 2867 /* On all machines, switch modem & serial ports off */
@@ -3013,9 +2889,6 @@ pmac_feature_init(void)
3013 return; 2889 return;
3014 } 2890 }
3015 2891
3016 /* Setup low-level i2c stuffs */
3017 pmac_init_low_i2c();
3018
3019 /* Probe machine type */ 2892 /* Probe machine type */
3020 if (probe_motherboard()) 2893 if (probe_motherboard())
3021 printk(KERN_WARNING "Unknown PowerMac !\n"); 2894 printk(KERN_WARNING "Unknown PowerMac !\n");