2 #include <linux/moduleparam.h>
5 #define PFX "ipmi_hardcode: "
7 * There can be 4 IO ports passed in (with or without IRQs), 4 addresses,
8 * a default IO port, and 1 ACPI/SPMI address. That sets SI_MAX_DRIVERS.
11 #define SI_MAX_PARMS 4
13 static char *si_type
[SI_MAX_PARMS
];
14 #define MAX_SI_TYPE_STR 30
15 static char si_type_str
[MAX_SI_TYPE_STR
];
16 static unsigned long addrs
[SI_MAX_PARMS
];
17 static unsigned int num_addrs
;
18 static unsigned int ports
[SI_MAX_PARMS
];
19 static unsigned int num_ports
;
20 static int irqs
[SI_MAX_PARMS
];
21 static unsigned int num_irqs
;
22 static int regspacings
[SI_MAX_PARMS
];
23 static unsigned int num_regspacings
;
24 static int regsizes
[SI_MAX_PARMS
];
25 static unsigned int num_regsizes
;
26 static int regshifts
[SI_MAX_PARMS
];
27 static unsigned int num_regshifts
;
28 static int slave_addrs
[SI_MAX_PARMS
]; /* Leaving 0 chooses the default value */
29 static unsigned int num_slave_addrs
;
31 module_param_string(type
, si_type_str
, MAX_SI_TYPE_STR
, 0);
32 MODULE_PARM_DESC(type
, "Defines the type of each interface, each"
33 " interface separated by commas. The types are 'kcs',"
34 " 'smic', and 'bt'. For example si_type=kcs,bt will set"
35 " the first interface to kcs and the second to bt");
36 module_param_hw_array(addrs
, ulong
, iomem
, &num_addrs
, 0);
37 MODULE_PARM_DESC(addrs
, "Sets the memory address of each interface, the"
38 " addresses separated by commas. Only use if an interface"
39 " is in memory. Otherwise, set it to zero or leave"
41 module_param_hw_array(ports
, uint
, ioport
, &num_ports
, 0);
42 MODULE_PARM_DESC(ports
, "Sets the port address of each interface, the"
43 " addresses separated by commas. Only use if an interface"
44 " is a port. Otherwise, set it to zero or leave"
46 module_param_hw_array(irqs
, int, irq
, &num_irqs
, 0);
47 MODULE_PARM_DESC(irqs
, "Sets the interrupt of each interface, the"
48 " addresses separated by commas. Only use if an interface"
49 " has an interrupt. Otherwise, set it to zero or leave"
51 module_param_hw_array(regspacings
, int, other
, &num_regspacings
, 0);
52 MODULE_PARM_DESC(regspacings
, "The number of bytes between the start address"
53 " and each successive register used by the interface. For"
54 " instance, if the start address is 0xca2 and the spacing"
55 " is 2, then the second address is at 0xca4. Defaults"
57 module_param_hw_array(regsizes
, int, other
, &num_regsizes
, 0);
58 MODULE_PARM_DESC(regsizes
, "The size of the specific IPMI register in bytes."
59 " This should generally be 1, 2, 4, or 8 for an 8-bit,"
60 " 16-bit, 32-bit, or 64-bit register. Use this if you"
61 " the 8-bit IPMI register has to be read from a larger"
63 module_param_hw_array(regshifts
, int, other
, &num_regshifts
, 0);
64 MODULE_PARM_DESC(regshifts
, "The amount to shift the data read from the."
65 " IPMI register, in bits. For instance, if the data"
66 " is read from a 32-bit word and the IPMI data is in"
67 " bit 8-15, then the shift would be 8");
68 module_param_hw_array(slave_addrs
, int, other
, &num_slave_addrs
, 0);
69 MODULE_PARM_DESC(slave_addrs
, "Set the default IPMB slave address for"
70 " the controller. Normally this is 0x20, but can be"
71 " overridden by this parm. This is an array indexed"
72 " by interface number.");
74 int ipmi_si_hardcode_find_bmc(void)
81 /* Parse out the si_type string into its components. */
84 for (i
= 0; (i
< SI_MAX_PARMS
) && (*str
!= '\0'); i
++) {
86 str
= strchr(str
, ',');
96 memset(&io
, 0, sizeof(io
));
97 for (i
= 0; i
< SI_MAX_PARMS
; i
++) {
98 if (!ports
[i
] && !addrs
[i
])
101 io
.addr_source
= SI_HARDCODED
;
102 pr_info(PFX
"probing via hardcoded address\n");
104 if (!si_type
[i
] || strcmp(si_type
[i
], "kcs") == 0) {
106 } else if (strcmp(si_type
[i
], "smic") == 0) {
107 io
.si_type
= SI_SMIC
;
108 } else if (strcmp(si_type
[i
], "bt") == 0) {
111 pr_warn(PFX
"Interface type specified for interface %d, was invalid: %s\n",
118 io
.addr_data
= ports
[i
];
119 io
.addr_type
= IPMI_IO_ADDR_SPACE
;
120 } else if (addrs
[i
]) {
122 io
.addr_data
= addrs
[i
];
123 io
.addr_type
= IPMI_MEM_ADDR_SPACE
;
125 pr_warn(PFX
"Interface type specified for interface %d, but port and address were not set or set to zero.\n",
131 io
.regspacing
= regspacings
[i
];
133 io
.regspacing
= DEFAULT_REGSPACING
;
134 io
.regsize
= regsizes
[i
];
136 io
.regsize
= DEFAULT_REGSIZE
;
137 io
.regshift
= regshifts
[i
];
140 io
.irq_setup
= ipmi_std_irq_setup
;
141 io
.slave_addr
= slave_addrs
[i
];
143 ret
= ipmi_si_add_smi(&io
);