diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-01-06 19:30:44 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-01-08 23:47:16 -0500 |
commit | 730745a5c45093982112ddc94cee6a9973455641 (patch) | |
tree | 1c36bd96c28d08e2b5d839ba3f4e37588aad2328 /include/asm-powerpc | |
parent | 002ec58eb57bac2380f0ed5a4e88121b4bdb32ec (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 'include/asm-powerpc')
-rw-r--r-- | include/asm-powerpc/pmac_feature.h | 4 | ||||
-rw-r--r-- | include/asm-powerpc/pmac_low_i2c.h | 85 | ||||
-rw-r--r-- | include/asm-powerpc/smu.h | 12 |
3 files changed, 77 insertions, 24 deletions
diff --git a/include/asm-powerpc/pmac_feature.h b/include/asm-powerpc/pmac_feature.h index f6997ed5179e..e654ad0e5b42 100644 --- a/include/asm-powerpc/pmac_feature.h +++ b/include/asm-powerpc/pmac_feature.h | |||
@@ -318,10 +318,6 @@ extern void pmac_register_agp_pm(struct pci_dev *bridge, | |||
318 | extern void pmac_suspend_agp_for_card(struct pci_dev *dev); | 318 | extern void pmac_suspend_agp_for_card(struct pci_dev *dev); |
319 | extern void pmac_resume_agp_for_card(struct pci_dev *dev); | 319 | extern void pmac_resume_agp_for_card(struct pci_dev *dev); |
320 | 320 | ||
321 | /* Used by the via-pmu driver for suspend/resume | ||
322 | */ | ||
323 | extern void pmac_tweak_clock_spreading(int enable); | ||
324 | |||
325 | /* | 321 | /* |
326 | * The part below is for use by macio_asic.c only, do not rely | 322 | * The part below is for use by macio_asic.c only, do not rely |
327 | * on the data structures or constants below in a normal driver | 323 | * on the data structures or constants below in a normal driver |
diff --git a/include/asm-powerpc/pmac_low_i2c.h b/include/asm-powerpc/pmac_low_i2c.h index 3fb8d51540dd..adf4fa956572 100644 --- a/include/asm-powerpc/pmac_low_i2c.h +++ b/include/asm-powerpc/pmac_low_i2c.h | |||
@@ -15,30 +15,87 @@ | |||
15 | 15 | ||
16 | /* i2c mode (based on the platform functions format) */ | 16 | /* i2c mode (based on the platform functions format) */ |
17 | enum { | 17 | enum { |
18 | pmac_low_i2c_mode_dumb = 1, | 18 | pmac_i2c_mode_dumb = 1, |
19 | pmac_low_i2c_mode_std = 2, | 19 | pmac_i2c_mode_std = 2, |
20 | pmac_low_i2c_mode_stdsub = 3, | 20 | pmac_i2c_mode_stdsub = 3, |
21 | pmac_low_i2c_mode_combined = 4, | 21 | pmac_i2c_mode_combined = 4, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | /* RW bit in address */ | 24 | /* RW bit in address */ |
25 | enum { | 25 | enum { |
26 | pmac_low_i2c_read = 0x01, | 26 | pmac_i2c_read = 0x01, |
27 | pmac_low_i2c_write = 0x00 | 27 | pmac_i2c_write = 0x00 |
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* i2c bus type */ | ||
31 | enum { | ||
32 | pmac_i2c_bus_keywest = 0, | ||
33 | pmac_i2c_bus_pmu = 1, | ||
34 | pmac_i2c_bus_smu = 2, | ||
35 | }; | ||
36 | |||
37 | /* i2c bus features */ | ||
38 | enum { | ||
39 | /* can_largesub : supports >1 byte subaddresses (SMU only) */ | ||
40 | pmac_i2c_can_largesub = 0x00000001u, | ||
41 | |||
42 | /* multibus : device node holds multiple busses, bus number is | ||
43 | * encoded in bits 0xff00 of "reg" of a given device | ||
44 | */ | ||
45 | pmac_i2c_multibus = 0x00000002u, | ||
46 | }; | ||
47 | |||
48 | /* i2c busses in the system */ | ||
49 | struct pmac_i2c_bus; | ||
50 | struct i2c_adapter; | ||
51 | |||
30 | /* Init, called early during boot */ | 52 | /* Init, called early during boot */ |
31 | extern void pmac_init_low_i2c(void); | 53 | extern int pmac_i2c_init(void); |
54 | |||
55 | /* Lookup an i2c bus for a device-node. The node can be either the bus | ||
56 | * node itself or a device below it. In the case of a multibus, the bus | ||
57 | * node itself is the controller node, else, it's a child of the controller | ||
58 | * node | ||
59 | */ | ||
60 | extern struct pmac_i2c_bus *pmac_i2c_find_bus(struct device_node *node); | ||
61 | |||
62 | /* Get the address for an i2c device. This strips the bus number if | ||
63 | * necessary. The 7 bits address is returned 1 bit right shifted so that the | ||
64 | * direction can be directly ored in | ||
65 | */ | ||
66 | extern u8 pmac_i2c_get_dev_addr(struct device_node *device); | ||
67 | |||
68 | /* Get infos about a bus */ | ||
69 | extern struct device_node *pmac_i2c_get_controller(struct pmac_i2c_bus *bus); | ||
70 | extern struct device_node *pmac_i2c_get_bus_node(struct pmac_i2c_bus *bus); | ||
71 | extern int pmac_i2c_get_type(struct pmac_i2c_bus *bus); | ||
72 | extern int pmac_i2c_get_flags(struct pmac_i2c_bus *bus); | ||
73 | |||
74 | /* i2c layer adapter attach/detach */ | ||
75 | extern void pmac_i2c_attach_adapter(struct pmac_i2c_bus *bus, | ||
76 | struct i2c_adapter *adapter); | ||
77 | extern void pmac_i2c_detach_adapter(struct pmac_i2c_bus *bus, | ||
78 | struct i2c_adapter *adapter); | ||
79 | extern struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus); | ||
80 | |||
81 | /* March a device or bus with an i2c adapter structure, to be used by drivers | ||
82 | * to match device-tree nodes with i2c adapters during adapter discovery | ||
83 | * callbacks | ||
84 | */ | ||
85 | extern int pmac_i2c_match_adapter(struct device_node *dev, | ||
86 | struct i2c_adapter *adapter); | ||
87 | |||
32 | 88 | ||
33 | /* Locking functions exposed to i2c-keywest */ | 89 | /* (legacy) Locking functions exposed to i2c-keywest */ |
34 | int pmac_low_i2c_lock(struct device_node *np); | 90 | extern int pmac_low_i2c_lock(struct device_node *np); |
35 | int pmac_low_i2c_unlock(struct device_node *np); | 91 | extern int pmac_low_i2c_unlock(struct device_node *np); |
36 | 92 | ||
37 | /* Access functions for platform code */ | 93 | /* Access functions for platform code */ |
38 | int pmac_low_i2c_open(struct device_node *np, int channel); | 94 | extern int pmac_i2c_open(struct pmac_i2c_bus *bus, int polled); |
39 | int pmac_low_i2c_close(struct device_node *np); | 95 | extern void pmac_i2c_close(struct pmac_i2c_bus *bus); |
40 | int pmac_low_i2c_setmode(struct device_node *np, int mode); | 96 | extern int pmac_i2c_setmode(struct pmac_i2c_bus *bus, int mode); |
41 | int pmac_low_i2c_xfer(struct device_node *np, u8 addrdir, u8 subaddr, u8 *data, int len); | 97 | extern int pmac_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize, |
98 | u32 subaddr, u8 *data, int len); | ||
42 | 99 | ||
43 | 100 | ||
44 | #endif /* __KERNEL__ */ | 101 | #endif /* __KERNEL__ */ |
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h index 7fae3ce9a8c1..134c2b5be0f2 100644 --- a/include/asm-powerpc/smu.h +++ b/include/asm-powerpc/smu.h | |||
@@ -358,6 +358,9 @@ extern unsigned long smu_cmdbuf_abs; | |||
358 | * Kenrel asynchronous i2c interface | 358 | * Kenrel asynchronous i2c interface |
359 | */ | 359 | */ |
360 | 360 | ||
361 | #define SMU_I2C_READ_MAX 0x1d | ||
362 | #define SMU_I2C_WRITE_MAX 0x15 | ||
363 | |||
361 | /* SMU i2c header, exactly matches i2c header on wire */ | 364 | /* SMU i2c header, exactly matches i2c header on wire */ |
362 | struct smu_i2c_param | 365 | struct smu_i2c_param |
363 | { | 366 | { |
@@ -368,12 +371,9 @@ struct smu_i2c_param | |||
368 | u8 subaddr[3]; /* subaddress */ | 371 | u8 subaddr[3]; /* subaddress */ |
369 | u8 caddr; /* combined address, filled by SMU driver */ | 372 | u8 caddr; /* combined address, filled by SMU driver */ |
370 | u8 datalen; /* length of transfer */ | 373 | u8 datalen; /* length of transfer */ |
371 | u8 data[7]; /* data */ | 374 | u8 data[SMU_I2C_READ_MAX]; /* data */ |
372 | }; | 375 | }; |
373 | 376 | ||
374 | #define SMU_I2C_READ_MAX 0x0d | ||
375 | #define SMU_I2C_WRITE_MAX 0x05 | ||
376 | |||
377 | struct smu_i2c_cmd | 377 | struct smu_i2c_cmd |
378 | { | 378 | { |
379 | /* public */ | 379 | /* public */ |
@@ -387,7 +387,7 @@ struct smu_i2c_cmd | |||
387 | int read; | 387 | int read; |
388 | int stage; | 388 | int stage; |
389 | int retries; | 389 | int retries; |
390 | u8 pdata[0x10]; | 390 | u8 pdata[32]; |
391 | struct list_head link; | 391 | struct list_head link; |
392 | }; | 392 | }; |
393 | 393 | ||
@@ -519,7 +519,7 @@ struct smu_sdbp_cpupiddata { | |||
519 | * if not found. The data format is described below | 519 | * if not found. The data format is described below |
520 | */ | 520 | */ |
521 | extern struct smu_sdbp_header *smu_get_sdb_partition(int id, | 521 | extern struct smu_sdbp_header *smu_get_sdb_partition(int id, |
522 | unsigned int *size); | 522 | unsigned int *size); |
523 | 523 | ||
524 | #endif /* __KERNEL__ */ | 524 | #endif /* __KERNEL__ */ |
525 | 525 | ||