aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus/char/envctrl.c
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/envctrl.c
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/envctrl.c')
-rw-r--r--drivers/sbus/char/envctrl.c71
1 files changed, 33 insertions, 38 deletions
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 }