aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus/char
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-22 22:12:03 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 02:15:28 -0400
commit690c8fd31f1e35985d0f35772fde514da59ec9d1 (patch)
tree8a5a0036b3780a9eb315ea2201a2562570de1ebe /drivers/sbus/char
parentde8d28b16f5614aeb12bb69c8f9a38578b8d3ada (diff)
[SPARC64]: Use in-kernel PROM tree for EBUS and ISA.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char')
-rw-r--r--drivers/sbus/char/bbc_envctrl.c4
-rw-r--r--drivers/sbus/char/bbc_i2c.c4
-rw-r--r--drivers/sbus/char/display7seg.c2
-rw-r--r--drivers/sbus/char/envctrl.c71
-rw-r--r--drivers/sbus/char/flash.c16
5 files changed, 47 insertions, 50 deletions
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index d89f83f769f5..1cc706e11119 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -575,9 +575,9 @@ int bbc_envctrl_init(void)
575 int devidx = 0; 575 int devidx = 0;
576 576
577 while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { 577 while ((echild = bbc_i2c_getdev(devidx++)) != NULL) {
578 if (!strcmp(echild->prom_name, "temperature")) 578 if (!strcmp(echild->prom_node->name, "temperature"))
579 attach_one_temp(echild, temp_index++); 579 attach_one_temp(echild, temp_index++);
580 if (!strcmp(echild->prom_name, "fan-control")) 580 if (!strcmp(echild->prom_node->name, "fan-control"))
581 attach_one_fan(echild, fan_index++); 581 attach_one_fan(echild, fan_index++);
582 } 582 }
583 if (temp_index != 0 && fan_index != 0) { 583 if (temp_index != 0 && fan_index != 0) {
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
index 3e156e005f2e..73634371393b 100644
--- a/drivers/sbus/char/bbc_i2c.c
+++ b/drivers/sbus/char/bbc_i2c.c
@@ -423,7 +423,7 @@ static int __init bbc_present(void)
423 423
424 for_each_ebus(ebus) { 424 for_each_ebus(ebus) {
425 for_each_ebusdev(edev, ebus) { 425 for_each_ebusdev(edev, ebus) {
426 if (!strcmp(edev->prom_name, "bbc")) 426 if (!strcmp(edev->prom_node->name, "bbc"))
427 return 1; 427 return 1;
428 } 428 }
429 } 429 }
@@ -446,7 +446,7 @@ static int __init bbc_i2c_init(void)
446 446
447 for_each_ebus(ebus) { 447 for_each_ebus(ebus) {
448 for_each_ebusdev(edev, ebus) { 448 for_each_ebusdev(edev, ebus) {
449 if (!strcmp(edev->prom_name, "i2c")) { 449 if (!strcmp(edev->prom_node->name, "i2c")) {
450 if (!attach_one_i2c(edev, index)) 450 if (!attach_one_i2c(edev, index))
451 index++; 451 index++;
452 } 452 }
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index c3a51d1fae5d..d92bc8827a9e 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -184,7 +184,7 @@ static int __init d7s_init(void)
184 184
185 for_each_ebus(ebus) { 185 for_each_ebus(ebus) {
186 for_each_ebusdev(edev, ebus) { 186 for_each_ebusdev(edev, ebus) {
187 if (!strcmp(edev->prom_name, D7S_OBPNAME)) 187 if (!strcmp(edev->prom_node->name, D7S_OBPNAME))
188 goto ebus_done; 188 goto ebus_done;
189 } 189 }
190 } 190 }
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 19e8eddf887a..cf97e9efe9b6 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -768,16 +768,14 @@ static void envctrl_set_mon(struct i2c_child_t *pchild,
768 * decoding tables, monitor type, optional properties. 768 * decoding tables, monitor type, optional properties.
769 * Return: None. 769 * Return: None.
770 */ 770 */
771static void envctrl_init_adc(struct i2c_child_t *pchild, int node) 771static void envctrl_init_adc(struct i2c_child_t *pchild, struct device_node *dp)
772{ 772{
773 char chnls_desc[CHANNEL_DESC_SZ];
774 int i = 0, len; 773 int i = 0, len;
775 char *pos = chnls_desc; 774 char *pos;
775 unsigned int *pval;
776 776
777 /* Firmware describe channels into a stream separated by a '\0'. */ 777 /* Firmware describe channels into a stream separated by a '\0'. */
778 len = prom_getproperty(node, "channels-description", chnls_desc, 778 pos = of_get_property(dp, "channels-description", &len);
779 CHANNEL_DESC_SZ);
780 chnls_desc[CHANNEL_DESC_SZ - 1] = '\0';
781 779
782 while (len > 0) { 780 while (len > 0) {
783 int l = strlen(pos) + 1; 781 int l = strlen(pos) + 1;
@@ -787,10 +785,13 @@ static void envctrl_init_adc(struct i2c_child_t *pchild, int node)
787 } 785 }
788 786
789 /* Get optional properties. */ 787 /* Get optional properties. */
790 len = prom_getproperty(node, "warning-temp", (char *)&warning_temperature, 788 pval = of_get_property(dp, "warning-temp", NULL);
791 sizeof(warning_temperature)); 789 if (pval)
792 len = prom_getproperty(node, "shutdown-temp", (char *)&shutdown_temperature, 790 warning_temperature = *pval;
793 sizeof(shutdown_temperature)); 791
792 pval = of_get_property(dp, "shutdown-temp", NULL);
793 if (pval)
794 shutdown_temperature = *pval;
794} 795}
795 796
796/* Function Description: Initialize child device monitoring fan status. 797/* Function Description: Initialize child device monitoring fan status.
@@ -864,21 +865,18 @@ static void envctrl_init_voltage_status(struct i2c_child_t *pchild)
864static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, 865static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
865 struct i2c_child_t *pchild) 866 struct i2c_child_t *pchild)
866{ 867{
867 int node, len, i, tbls_size = 0; 868 int len, i, tbls_size = 0;
868 869 struct device_node *dp = edev_child->prom_node;
869 node = edev_child->prom_node; 870 void *pval;
870 871
871 /* Get device address. */ 872 /* Get device address. */
872 len = prom_getproperty(node, "reg", 873 pval = of_get_property(dp, "reg", &len);
873 (char *) &(pchild->addr), 874 memcpy(&pchild->addr, pval, len);
874 sizeof(pchild->addr));
875 875
876 /* Get tables property. Read firmware temperature tables. */ 876 /* Get tables property. Read firmware temperature tables. */
877 len = prom_getproperty(node, "translation", 877 pval = of_get_property(dp, "translation", &len);
878 (char *) pchild->tblprop_array, 878 if (pval && len > 0) {
879 (PCF8584_MAX_CHANNELS * 879 memcpy(pchild->tblprop_array, pval, len);
880 sizeof(struct pcf8584_tblprop)));
881 if (len > 0) {
882 pchild->total_tbls = len / sizeof(struct pcf8584_tblprop); 880 pchild->total_tbls = len / sizeof(struct pcf8584_tblprop);
883 for (i = 0; i < pchild->total_tbls; i++) { 881 for (i = 0; i < pchild->total_tbls; i++) {
884 if ((pchild->tblprop_array[i].size + pchild->tblprop_array[i].offset) > tbls_size) { 882 if ((pchild->tblprop_array[i].size + pchild->tblprop_array[i].offset) > tbls_size) {
@@ -891,12 +889,12 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
891 printk("envctrl: Failed to allocate table.\n"); 889 printk("envctrl: Failed to allocate table.\n");
892 return; 890 return;
893 } 891 }
894 len = prom_getproperty(node, "tables", 892 pval = of_get_property(dp, "tables", &len);
895 (char *) pchild->tables, tbls_size); 893 if (!pval || len <= 0) {
896 if (len <= 0) {
897 printk("envctrl: Failed to get table.\n"); 894 printk("envctrl: Failed to get table.\n");
898 return; 895 return;
899 } 896 }
897 memcpy(pchild->tables, pval, len);
900 } 898 }
901 899
902 /* SPARCengine ASM Reference Manual (ref. SMI doc 805-7581-04) 900 /* SPARCengine ASM Reference Manual (ref. SMI doc 805-7581-04)
@@ -907,12 +905,11 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
907 * 'NULL' monitor type. 905 * 'NULL' monitor type.
908 */ 906 */
909 if (ENVCTRL_CPCI_IGNORED_NODE == pchild->addr) { 907 if (ENVCTRL_CPCI_IGNORED_NODE == pchild->addr) {
908 struct device_node *root_node;
910 int len; 909 int len;
911 char prop[56];
912 910
913 len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); 911 root_node = of_find_node_by_path("/");
914 if (0 < len && (0 == strncmp(prop, "SUNW,UltraSPARC-IIi-cEngine", len))) 912 if (!strcmp(root_node->name, "SUNW,UltraSPARC-IIi-cEngine")) {
915 {
916 for (len = 0; len < PCF8584_MAX_CHANNELS; ++len) { 913 for (len = 0; len < PCF8584_MAX_CHANNELS; ++len) {
917 pchild->mon_type[len] = ENVCTRL_NOMON; 914 pchild->mon_type[len] = ENVCTRL_NOMON;
918 } 915 }
@@ -921,16 +918,14 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
921 } 918 }
922 919
923 /* Get the monitor channels. */ 920 /* Get the monitor channels. */
924 len = prom_getproperty(node, "channels-in-use", 921 pval = of_get_property(dp, "channels-in-use", &len);
925 (char *) pchild->chnl_array, 922 memcpy(pchild->chnl_array, pval, len);
926 (PCF8584_MAX_CHANNELS *
927 sizeof(struct pcf8584_channel)));
928 pchild->total_chnls = len / sizeof(struct pcf8584_channel); 923 pchild->total_chnls = len / sizeof(struct pcf8584_channel);
929 924
930 for (i = 0; i < pchild->total_chnls; i++) { 925 for (i = 0; i < pchild->total_chnls; i++) {
931 switch (pchild->chnl_array[i].type) { 926 switch (pchild->chnl_array[i].type) {
932 case PCF8584_TEMP_TYPE: 927 case PCF8584_TEMP_TYPE:
933 envctrl_init_adc(pchild, node); 928 envctrl_init_adc(pchild, dp);
934 break; 929 break;
935 930
936 case PCF8584_GLOBALADDR_TYPE: 931 case PCF8584_GLOBALADDR_TYPE:
@@ -945,7 +940,7 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
945 940
946 case PCF8584_VOLTAGE_TYPE: 941 case PCF8584_VOLTAGE_TYPE:
947 if (pchild->i2ctype == I2C_ADC) { 942 if (pchild->i2ctype == I2C_ADC) {
948 envctrl_init_adc(pchild,node); 943 envctrl_init_adc(pchild,dp);
949 } else { 944 } else {
950 envctrl_init_voltage_status(pchild); 945 envctrl_init_voltage_status(pchild);
951 } 946 }
@@ -1046,7 +1041,7 @@ static int __init envctrl_init(void)
1046 1041
1047 for_each_ebus(ebus) { 1042 for_each_ebus(ebus) {
1048 for_each_ebusdev(edev, ebus) { 1043 for_each_ebusdev(edev, ebus) {
1049 if (!strcmp(edev->prom_name, "bbc")) { 1044 if (!strcmp(edev->prom_node->name, "bbc")) {
1050 /* If we find a boot-bus controller node, 1045 /* If we find a boot-bus controller node,
1051 * then this envctrl driver is not for us. 1046 * then this envctrl driver is not for us.
1052 */ 1047 */
@@ -1060,14 +1055,14 @@ static int __init envctrl_init(void)
1060 */ 1055 */
1061 for_each_ebus(ebus) { 1056 for_each_ebus(ebus) {
1062 for_each_ebusdev(edev, ebus) { 1057 for_each_ebusdev(edev, ebus) {
1063 if (!strcmp(edev->prom_name, "i2c")) { 1058 if (!strcmp(edev->prom_node->name, "i2c")) {
1064 i2c = ioremap(edev->resource[0].start, 0x2); 1059 i2c = ioremap(edev->resource[0].start, 0x2);
1065 for_each_edevchild(edev, edev_child) { 1060 for_each_edevchild(edev, edev_child) {
1066 if (!strcmp("gpio", edev_child->prom_name)) { 1061 if (!strcmp("gpio", edev_child->prom_node->name)) {
1067 i2c_childlist[i].i2ctype = I2C_GPIO; 1062 i2c_childlist[i].i2ctype = I2C_GPIO;
1068 envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); 1063 envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++]));
1069 } 1064 }
1070 if (!strcmp("adc", edev_child->prom_name)) { 1065 if (!strcmp("adc", edev_child->prom_node->name)) {
1071 i2c_childlist[i].i2ctype = I2C_ADC; 1066 i2c_childlist[i].i2ctype = I2C_ADC;
1072 envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); 1067 envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++]));
1073 } 1068 }
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
index 2beb3dded087..5ae684c011f8 100644
--- a/drivers/sbus/char/flash.c
+++ b/drivers/sbus/char/flash.c
@@ -192,9 +192,11 @@ static int __init flash_init(void)
192 } 192 }
193 if (!sdev) { 193 if (!sdev) {
194#ifdef CONFIG_PCI 194#ifdef CONFIG_PCI
195 struct linux_prom_registers *ebus_regs;
196
195 for_each_ebus(ebus) { 197 for_each_ebus(ebus) {
196 for_each_ebusdev(edev, ebus) { 198 for_each_ebusdev(edev, ebus) {
197 if (!strcmp(edev->prom_name, "flashprom")) 199 if (!strcmp(edev->prom_node->name, "flashprom"))
198 goto ebus_done; 200 goto ebus_done;
199 } 201 }
200 } 202 }
@@ -202,23 +204,23 @@ static int __init flash_init(void)
202 if (!edev) 204 if (!edev)
203 return -ENODEV; 205 return -ENODEV;
204 206
205 len = prom_getproperty(edev->prom_node, "reg", (void *)regs, sizeof(regs)); 207 ebus_regs = of_get_property(edev->prom_node, "reg", &len);
206 if ((len % sizeof(regs[0])) != 0) { 208 if (!ebus_regs || (len % sizeof(regs[0])) != 0) {
207 printk("flash: Strange reg property size %d\n", len); 209 printk("flash: Strange reg property size %d\n", len);
208 return -ENODEV; 210 return -ENODEV;
209 } 211 }
210 212
211 nregs = len / sizeof(regs[0]); 213 nregs = len / sizeof(ebus_regs[0]);
212 214
213 flash.read_base = edev->resource[0].start; 215 flash.read_base = edev->resource[0].start;
214 flash.read_size = regs[0].reg_size; 216 flash.read_size = ebus_regs[0].reg_size;
215 217
216 if (nregs == 1) { 218 if (nregs == 1) {
217 flash.write_base = edev->resource[0].start; 219 flash.write_base = edev->resource[0].start;
218 flash.write_size = regs[0].reg_size; 220 flash.write_size = ebus_regs[0].reg_size;
219 } else if (nregs == 2) { 221 } else if (nregs == 2) {
220 flash.write_base = edev->resource[1].start; 222 flash.write_base = edev->resource[1].start;
221 flash.write_size = regs[1].reg_size; 223 flash.write_size = ebus_regs[1].reg_size;
222 } else { 224 } else {
223 printk("flash: Strange number of regs %d\n", nregs); 225 printk("flash: Strange number of regs %d\n", nregs);
224 return -ENODEV; 226 return -ENODEV;