ibmphp.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. #ifndef __IBMPHP_H
  2. #define __IBMPHP_H
  3. /*
  4. * IBM Hot Plug Controller Driver
  5. *
  6. * Written By: Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
  7. *
  8. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  9. * Copyright (C) 2001-2003 IBM Corp.
  10. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or (at
  16. * your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful, but
  19. * WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21. * NON INFRINGEMENT. See the GNU General Public License for more
  22. * details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. *
  28. * Send feedback to <gregkh@us.ibm.com>
  29. *
  30. */
  31. #include <linux/pci_hotplug.h>
  32. extern int ibmphp_debug;
  33. #if !defined(MODULE)
  34. #define MY_NAME "ibmphpd"
  35. #else
  36. #define MY_NAME THIS_MODULE->name
  37. #endif
  38. #define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0)
  39. #define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0)
  40. #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
  41. #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
  42. #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
  43. /* EBDA stuff */
  44. /***********************************************************
  45. * SLOT CAPABILITY *
  46. ***********************************************************/
  47. #define EBDA_SLOT_133_MAX 0x20
  48. #define EBDA_SLOT_100_MAX 0x10
  49. #define EBDA_SLOT_66_MAX 0x02
  50. #define EBDA_SLOT_PCIX_CAP 0x08
  51. /************************************************************
  52. * RESOURCE TYPE *
  53. ************************************************************/
  54. #define EBDA_RSRC_TYPE_MASK 0x03
  55. #define EBDA_IO_RSRC_TYPE 0x00
  56. #define EBDA_MEM_RSRC_TYPE 0x01
  57. #define EBDA_PFM_RSRC_TYPE 0x03
  58. #define EBDA_RES_RSRC_TYPE 0x02
  59. /*************************************************************
  60. * IO RESTRICTION TYPE *
  61. *************************************************************/
  62. #define EBDA_IO_RESTRI_MASK 0x0c
  63. #define EBDA_NO_RESTRI 0x00
  64. #define EBDA_AVO_VGA_ADDR 0x04
  65. #define EBDA_AVO_VGA_ADDR_AND_ALIA 0x08
  66. #define EBDA_AVO_ISA_ADDR 0x0c
  67. /**************************************************************
  68. * DEVICE TYPE DEF *
  69. **************************************************************/
  70. #define EBDA_DEV_TYPE_MASK 0x10
  71. #define EBDA_PCI_DEV 0x10
  72. #define EBDA_NON_PCI_DEV 0x00
  73. /***************************************************************
  74. * PRIMARY DEF DEFINITION *
  75. ***************************************************************/
  76. #define EBDA_PRI_DEF_MASK 0x20
  77. #define EBDA_PRI_PCI_BUS_INFO 0x20
  78. #define EBDA_NORM_DEV_RSRC_INFO 0x00
  79. //--------------------------------------------------------------
  80. // RIO TABLE DATA STRUCTURE
  81. //--------------------------------------------------------------
  82. struct rio_table_hdr {
  83. u8 ver_num;
  84. u8 scal_count;
  85. u8 riodev_count;
  86. u16 offset;
  87. };
  88. //-------------------------------------------------------------
  89. // SCALABILITY DETAIL
  90. //-------------------------------------------------------------
  91. struct scal_detail {
  92. u8 node_id;
  93. u32 cbar;
  94. u8 port0_node_connect;
  95. u8 port0_port_connect;
  96. u8 port1_node_connect;
  97. u8 port1_port_connect;
  98. u8 port2_node_connect;
  99. u8 port2_port_connect;
  100. u8 chassis_num;
  101. // struct list_head scal_detail_list;
  102. };
  103. //--------------------------------------------------------------
  104. // RIO DETAIL
  105. //--------------------------------------------------------------
  106. struct rio_detail {
  107. u8 rio_node_id;
  108. u32 bbar;
  109. u8 rio_type;
  110. u8 owner_id;
  111. u8 port0_node_connect;
  112. u8 port0_port_connect;
  113. u8 port1_node_connect;
  114. u8 port1_port_connect;
  115. u8 first_slot_num;
  116. u8 status;
  117. u8 wpindex;
  118. u8 chassis_num;
  119. struct list_head rio_detail_list;
  120. };
  121. struct opt_rio {
  122. u8 rio_type;
  123. u8 chassis_num;
  124. u8 first_slot_num;
  125. u8 middle_num;
  126. struct list_head opt_rio_list;
  127. };
  128. struct opt_rio_lo {
  129. u8 rio_type;
  130. u8 chassis_num;
  131. u8 first_slot_num;
  132. u8 middle_num;
  133. u8 pack_count;
  134. struct list_head opt_rio_lo_list;
  135. };
  136. /****************************************************************
  137. * HPC DESCRIPTOR NODE *
  138. ****************************************************************/
  139. struct ebda_hpc_list {
  140. u8 format;
  141. u16 num_ctlrs;
  142. short phys_addr;
  143. // struct list_head ebda_hpc_list;
  144. };
  145. /*****************************************************************
  146. * IN HPC DATA STRUCTURE, THE ASSOCIATED SLOT AND BUS *
  147. * STRUCTURE *
  148. *****************************************************************/
  149. struct ebda_hpc_slot {
  150. u8 slot_num;
  151. u32 slot_bus_num;
  152. u8 ctl_index;
  153. u8 slot_cap;
  154. };
  155. struct ebda_hpc_bus {
  156. u32 bus_num;
  157. u8 slots_at_33_conv;
  158. u8 slots_at_66_conv;
  159. u8 slots_at_66_pcix;
  160. u8 slots_at_100_pcix;
  161. u8 slots_at_133_pcix;
  162. };
  163. /********************************************************************
  164. * THREE TYPE OF HOT PLUG CONTROLLER *
  165. ********************************************************************/
  166. struct isa_ctlr_access {
  167. u16 io_start;
  168. u16 io_end;
  169. };
  170. struct pci_ctlr_access {
  171. u8 bus;
  172. u8 dev_fun;
  173. };
  174. struct wpeg_i2c_ctlr_access {
  175. ulong wpegbbar;
  176. u8 i2c_addr;
  177. };
  178. #define HPC_DEVICE_ID 0x0246
  179. #define HPC_SUBSYSTEM_ID 0x0247
  180. #define HPC_PCI_OFFSET 0x40
  181. /*************************************************************************
  182. * RSTC DESCRIPTOR NODE *
  183. *************************************************************************/
  184. struct ebda_rsrc_list {
  185. u8 format;
  186. u16 num_entries;
  187. u16 phys_addr;
  188. struct ebda_rsrc_list *next;
  189. };
  190. /***************************************************************************
  191. * PCI RSRC NODE *
  192. ***************************************************************************/
  193. struct ebda_pci_rsrc {
  194. u8 rsrc_type;
  195. u8 bus_num;
  196. u8 dev_fun;
  197. u32 start_addr;
  198. u32 end_addr;
  199. u8 marked; /* for NVRAM */
  200. struct list_head ebda_pci_rsrc_list;
  201. };
  202. /***********************************************************
  203. * BUS_INFO DATE STRUCTURE *
  204. ***********************************************************/
  205. struct bus_info {
  206. u8 slot_min;
  207. u8 slot_max;
  208. u8 slot_count;
  209. u8 busno;
  210. u8 controller_id;
  211. u8 current_speed;
  212. u8 current_bus_mode;
  213. u8 index;
  214. u8 slots_at_33_conv;
  215. u8 slots_at_66_conv;
  216. u8 slots_at_66_pcix;
  217. u8 slots_at_100_pcix;
  218. u8 slots_at_133_pcix;
  219. struct list_head bus_info_list;
  220. };
  221. /***********************************************************
  222. * GLOBAL VARIABLES *
  223. ***********************************************************/
  224. extern struct list_head ibmphp_ebda_pci_rsrc_head;
  225. extern struct list_head ibmphp_slot_head;
  226. /***********************************************************
  227. * FUNCTION PROTOTYPES *
  228. ***********************************************************/
  229. void ibmphp_free_ebda_hpc_queue(void);
  230. int ibmphp_access_ebda(void);
  231. struct slot *ibmphp_get_slot_from_physical_num(u8);
  232. int ibmphp_get_total_hp_slots(void);
  233. void ibmphp_free_ibm_slot(struct slot *);
  234. void ibmphp_free_bus_info_queue(void);
  235. void ibmphp_free_ebda_pci_rsrc_queue(void);
  236. struct bus_info *ibmphp_find_same_bus_num(u32);
  237. int ibmphp_get_bus_index(u8);
  238. u16 ibmphp_get_total_controllers(void);
  239. int ibmphp_register_pci(void);
  240. /* passed parameters */
  241. #define MEM 0
  242. #define IO 1
  243. #define PFMEM 2
  244. /* bit masks */
  245. #define RESTYPE 0x03
  246. #define IOMASK 0x00 /* will need to take its complement */
  247. #define MMASK 0x01
  248. #define PFMASK 0x03
  249. #define PCIDEVMASK 0x10 /* we should always have PCI devices */
  250. #define PRIMARYBUSMASK 0x20
  251. /* pci specific defines */
  252. #define PCI_VENDOR_ID_NOTVALID 0xFFFF
  253. #define PCI_HEADER_TYPE_MULTIDEVICE 0x80
  254. #define PCI_HEADER_TYPE_MULTIBRIDGE 0x81
  255. #define LATENCY 0x64
  256. #define CACHE 64
  257. #define DEVICEENABLE 0x015F /* CPQ has 0x0157 */
  258. #define IOBRIDGE 0x1000 /* 4k */
  259. #define MEMBRIDGE 0x100000 /* 1M */
  260. /* irqs */
  261. #define SCSI_IRQ 0x09
  262. #define LAN_IRQ 0x0A
  263. #define OTHER_IRQ 0x0B
  264. /* Data Structures */
  265. /* type is of the form x x xx xx
  266. * | | | |_ 00 - I/O, 01 - Memory, 11 - PFMemory
  267. * | | - 00 - No Restrictions, 01 - Avoid VGA, 10 - Avoid
  268. * | | VGA and their aliases, 11 - Avoid ISA
  269. * | - 1 - PCI device, 0 - non pci device
  270. * - 1 - Primary PCI Bus Information (0 if Normal device)
  271. * the IO restrictions [2:3] are only for primary buses
  272. */
  273. /* we need this struct because there could be several resource blocks
  274. * allocated per primary bus in the EBDA
  275. */
  276. struct range_node {
  277. int rangeno;
  278. u32 start;
  279. u32 end;
  280. struct range_node *next;
  281. };
  282. struct bus_node {
  283. u8 busno;
  284. int noIORanges;
  285. struct range_node *rangeIO;
  286. int noMemRanges;
  287. struct range_node *rangeMem;
  288. int noPFMemRanges;
  289. struct range_node *rangePFMem;
  290. int needIOUpdate;
  291. int needMemUpdate;
  292. int needPFMemUpdate;
  293. struct resource_node *firstIO; /* first IO resource on the Bus */
  294. struct resource_node *firstMem; /* first memory resource on the Bus */
  295. struct resource_node *firstPFMem; /* first prefetchable memory resource on the Bus */
  296. struct resource_node *firstPFMemFromMem; /* when run out of pfmem available, taking from Mem */
  297. struct list_head bus_list;
  298. };
  299. struct resource_node {
  300. int rangeno;
  301. u8 busno;
  302. u8 devfunc;
  303. u32 start;
  304. u32 end;
  305. u32 len;
  306. int type; /* MEM, IO, PFMEM */
  307. u8 fromMem; /* this is to indicate that the range is from
  308. * from the Memory bucket rather than from PFMem */
  309. struct resource_node *next;
  310. struct resource_node *nextRange; /* for the other mem range on bus */
  311. };
  312. struct res_needed {
  313. u32 mem;
  314. u32 pfmem;
  315. u32 io;
  316. u8 not_correct; /* needed for return */
  317. int devices[32]; /* for device numbers behind this bridge */
  318. };
  319. /* functions */
  320. int ibmphp_rsrc_init(void);
  321. int ibmphp_add_resource(struct resource_node *);
  322. int ibmphp_remove_resource(struct resource_node *);
  323. int ibmphp_find_resource(struct bus_node *, u32, struct resource_node **, int);
  324. int ibmphp_check_resource(struct resource_node *, u8);
  325. int ibmphp_remove_bus(struct bus_node *, u8);
  326. void ibmphp_free_resources(void);
  327. int ibmphp_add_pfmem_from_mem(struct resource_node *);
  328. struct bus_node *ibmphp_find_res_bus(u8);
  329. void ibmphp_print_test(void); /* for debugging purposes */
  330. void ibmphp_hpc_initvars(void);
  331. int ibmphp_hpc_readslot(struct slot *, u8, u8 *);
  332. int ibmphp_hpc_writeslot(struct slot *, u8);
  333. void ibmphp_lock_operations(void);
  334. void ibmphp_unlock_operations(void);
  335. int ibmphp_hpc_start_poll_thread(void);
  336. void ibmphp_hpc_stop_poll_thread(void);
  337. //----------------------------------------------------------------------------
  338. //----------------------------------------------------------------------------
  339. // HPC return codes
  340. //----------------------------------------------------------------------------
  341. #define HPC_ERROR 0xFF
  342. //-----------------------------------------------------------------------------
  343. // BUS INFO
  344. //-----------------------------------------------------------------------------
  345. #define BUS_SPEED 0x30
  346. #define BUS_MODE 0x40
  347. #define BUS_MODE_PCIX 0x01
  348. #define BUS_MODE_PCI 0x00
  349. #define BUS_SPEED_2 0x20
  350. #define BUS_SPEED_1 0x10
  351. #define BUS_SPEED_33 0x00
  352. #define BUS_SPEED_66 0x01
  353. #define BUS_SPEED_100 0x02
  354. #define BUS_SPEED_133 0x03
  355. #define BUS_SPEED_66PCIX 0x04
  356. #define BUS_SPEED_66UNKNOWN 0x05
  357. #define BUS_STATUS_AVAILABLE 0x01
  358. #define BUS_CONTROL_AVAILABLE 0x02
  359. #define SLOT_LATCH_REGS_SUPPORTED 0x10
  360. #define PRGM_MODEL_REV_LEVEL 0xF0
  361. #define MAX_ADAPTER_NONE 0x09
  362. //----------------------------------------------------------------------------
  363. // HPC 'write' operations/commands
  364. //----------------------------------------------------------------------------
  365. // Command Code State Write to reg
  366. // Machine at index
  367. //------------------------- ---- ------- ------------
  368. #define HPC_CTLR_ENABLEIRQ 0x00 // N 15
  369. #define HPC_CTLR_DISABLEIRQ 0x01 // N 15
  370. #define HPC_SLOT_OFF 0x02 // Y 0-14
  371. #define HPC_SLOT_ON 0x03 // Y 0-14
  372. #define HPC_SLOT_ATTNOFF 0x04 // N 0-14
  373. #define HPC_SLOT_ATTNON 0x05 // N 0-14
  374. #define HPC_CTLR_CLEARIRQ 0x06 // N 15
  375. #define HPC_CTLR_RESET 0x07 // Y 15
  376. #define HPC_CTLR_IRQSTEER 0x08 // N 15
  377. #define HPC_BUS_33CONVMODE 0x09 // Y 31-34
  378. #define HPC_BUS_66CONVMODE 0x0A // Y 31-34
  379. #define HPC_BUS_66PCIXMODE 0x0B // Y 31-34
  380. #define HPC_BUS_100PCIXMODE 0x0C // Y 31-34
  381. #define HPC_BUS_133PCIXMODE 0x0D // Y 31-34
  382. #define HPC_ALLSLOT_OFF 0x11 // Y 15
  383. #define HPC_ALLSLOT_ON 0x12 // Y 15
  384. #define HPC_SLOT_BLINKLED 0x13 // N 0-14
  385. //----------------------------------------------------------------------------
  386. // read commands
  387. //----------------------------------------------------------------------------
  388. #define READ_SLOTSTATUS 0x01
  389. #define READ_EXTSLOTSTATUS 0x02
  390. #define READ_BUSSTATUS 0x03
  391. #define READ_CTLRSTATUS 0x04
  392. #define READ_ALLSTAT 0x05
  393. #define READ_ALLSLOT 0x06
  394. #define READ_SLOTLATCHLOWREG 0x07
  395. #define READ_REVLEVEL 0x08
  396. #define READ_HPCOPTIONS 0x09
  397. //----------------------------------------------------------------------------
  398. // slot status
  399. //----------------------------------------------------------------------------
  400. #define HPC_SLOT_POWER 0x01
  401. #define HPC_SLOT_CONNECT 0x02
  402. #define HPC_SLOT_ATTN 0x04
  403. #define HPC_SLOT_PRSNT2 0x08
  404. #define HPC_SLOT_PRSNT1 0x10
  405. #define HPC_SLOT_PWRGD 0x20
  406. #define HPC_SLOT_BUS_SPEED 0x40
  407. #define HPC_SLOT_LATCH 0x80
  408. //----------------------------------------------------------------------------
  409. // HPC_SLOT_POWER status return codes
  410. //----------------------------------------------------------------------------
  411. #define HPC_SLOT_POWER_OFF 0x00
  412. #define HPC_SLOT_POWER_ON 0x01
  413. //----------------------------------------------------------------------------
  414. // HPC_SLOT_CONNECT status return codes
  415. //----------------------------------------------------------------------------
  416. #define HPC_SLOT_CONNECTED 0x00
  417. #define HPC_SLOT_DISCONNECTED 0x01
  418. //----------------------------------------------------------------------------
  419. // HPC_SLOT_ATTN status return codes
  420. //----------------------------------------------------------------------------
  421. #define HPC_SLOT_ATTN_OFF 0x00
  422. #define HPC_SLOT_ATTN_ON 0x01
  423. #define HPC_SLOT_ATTN_BLINK 0x02
  424. //----------------------------------------------------------------------------
  425. // HPC_SLOT_PRSNT status return codes
  426. //----------------------------------------------------------------------------
  427. #define HPC_SLOT_EMPTY 0x00
  428. #define HPC_SLOT_PRSNT_7 0x01
  429. #define HPC_SLOT_PRSNT_15 0x02
  430. #define HPC_SLOT_PRSNT_25 0x03
  431. //----------------------------------------------------------------------------
  432. // HPC_SLOT_PWRGD status return codes
  433. //----------------------------------------------------------------------------
  434. #define HPC_SLOT_PWRGD_FAULT_NONE 0x00
  435. #define HPC_SLOT_PWRGD_GOOD 0x01
  436. //----------------------------------------------------------------------------
  437. // HPC_SLOT_BUS_SPEED status return codes
  438. //----------------------------------------------------------------------------
  439. #define HPC_SLOT_BUS_SPEED_OK 0x00
  440. #define HPC_SLOT_BUS_SPEED_MISM 0x01
  441. //----------------------------------------------------------------------------
  442. // HPC_SLOT_LATCH status return codes
  443. //----------------------------------------------------------------------------
  444. #define HPC_SLOT_LATCH_OPEN 0x01 // NOTE : in PCI spec bit off = open
  445. #define HPC_SLOT_LATCH_CLOSED 0x00 // NOTE : in PCI spec bit on = closed
  446. //----------------------------------------------------------------------------
  447. // extended slot status
  448. //----------------------------------------------------------------------------
  449. #define HPC_SLOT_PCIX 0x01
  450. #define HPC_SLOT_SPEED1 0x02
  451. #define HPC_SLOT_SPEED2 0x04
  452. #define HPC_SLOT_BLINK_ATTN 0x08
  453. #define HPC_SLOT_RSRVD1 0x10
  454. #define HPC_SLOT_RSRVD2 0x20
  455. #define HPC_SLOT_BUS_MODE 0x40
  456. #define HPC_SLOT_RSRVD3 0x80
  457. //----------------------------------------------------------------------------
  458. // HPC_XSLOT_PCIX_CAP status return codes
  459. //----------------------------------------------------------------------------
  460. #define HPC_SLOT_PCIX_NO 0x00
  461. #define HPC_SLOT_PCIX_YES 0x01
  462. //----------------------------------------------------------------------------
  463. // HPC_XSLOT_SPEED status return codes
  464. //----------------------------------------------------------------------------
  465. #define HPC_SLOT_SPEED_33 0x00
  466. #define HPC_SLOT_SPEED_66 0x01
  467. #define HPC_SLOT_SPEED_133 0x02
  468. //----------------------------------------------------------------------------
  469. // HPC_XSLOT_ATTN_BLINK status return codes
  470. //----------------------------------------------------------------------------
  471. #define HPC_SLOT_ATTN_BLINK_OFF 0x00
  472. #define HPC_SLOT_ATTN_BLINK_ON 0x01
  473. //----------------------------------------------------------------------------
  474. // HPC_XSLOT_BUS_MODE status return codes
  475. //----------------------------------------------------------------------------
  476. #define HPC_SLOT_BUS_MODE_OK 0x00
  477. #define HPC_SLOT_BUS_MODE_MISM 0x01
  478. //----------------------------------------------------------------------------
  479. // Controller status
  480. //----------------------------------------------------------------------------
  481. #define HPC_CTLR_WORKING 0x01
  482. #define HPC_CTLR_FINISHED 0x02
  483. #define HPC_CTLR_RESULT0 0x04
  484. #define HPC_CTLR_RESULT1 0x08
  485. #define HPC_CTLR_RESULE2 0x10
  486. #define HPC_CTLR_RESULT3 0x20
  487. #define HPC_CTLR_IRQ_ROUTG 0x40
  488. #define HPC_CTLR_IRQ_PENDG 0x80
  489. //----------------------------------------------------------------------------
  490. // HPC_CTLR_WORKING status return codes
  491. //----------------------------------------------------------------------------
  492. #define HPC_CTLR_WORKING_NO 0x00
  493. #define HPC_CTLR_WORKING_YES 0x01
  494. //----------------------------------------------------------------------------
  495. // HPC_CTLR_FINISHED status return codes
  496. //----------------------------------------------------------------------------
  497. #define HPC_CTLR_FINISHED_NO 0x00
  498. #define HPC_CTLR_FINISHED_YES 0x01
  499. //----------------------------------------------------------------------------
  500. // HPC_CTLR_RESULT status return codes
  501. //----------------------------------------------------------------------------
  502. #define HPC_CTLR_RESULT_SUCCESS 0x00
  503. #define HPC_CTLR_RESULT_FAILED 0x01
  504. #define HPC_CTLR_RESULT_RSVD 0x02
  505. #define HPC_CTLR_RESULT_NORESP 0x03
  506. //----------------------------------------------------------------------------
  507. // macro for slot info
  508. //----------------------------------------------------------------------------
  509. #define SLOT_POWER(s) ((u8) ((s & HPC_SLOT_POWER) \
  510. ? HPC_SLOT_POWER_ON : HPC_SLOT_POWER_OFF))
  511. #define SLOT_CONNECT(s) ((u8) ((s & HPC_SLOT_CONNECT) \
  512. ? HPC_SLOT_DISCONNECTED : HPC_SLOT_CONNECTED))
  513. #define SLOT_ATTN(s,es) ((u8) ((es & HPC_SLOT_BLINK_ATTN) \
  514. ? HPC_SLOT_ATTN_BLINK \
  515. : ((s & HPC_SLOT_ATTN) ? HPC_SLOT_ATTN_ON : HPC_SLOT_ATTN_OFF)))
  516. #define SLOT_PRESENT(s) ((u8) ((s & HPC_SLOT_PRSNT1) \
  517. ? ((s & HPC_SLOT_PRSNT2) ? HPC_SLOT_EMPTY : HPC_SLOT_PRSNT_15) \
  518. : ((s & HPC_SLOT_PRSNT2) ? HPC_SLOT_PRSNT_25 : HPC_SLOT_PRSNT_7)))
  519. #define SLOT_PWRGD(s) ((u8) ((s & HPC_SLOT_PWRGD) \
  520. ? HPC_SLOT_PWRGD_GOOD : HPC_SLOT_PWRGD_FAULT_NONE))
  521. #define SLOT_BUS_SPEED(s) ((u8) ((s & HPC_SLOT_BUS_SPEED) \
  522. ? HPC_SLOT_BUS_SPEED_MISM : HPC_SLOT_BUS_SPEED_OK))
  523. #define SLOT_LATCH(s) ((u8) ((s & HPC_SLOT_LATCH) \
  524. ? HPC_SLOT_LATCH_CLOSED : HPC_SLOT_LATCH_OPEN))
  525. #define SLOT_PCIX(es) ((u8) ((es & HPC_SLOT_PCIX) \
  526. ? HPC_SLOT_PCIX_YES : HPC_SLOT_PCIX_NO))
  527. #define SLOT_SPEED(es) ((u8) ((es & HPC_SLOT_SPEED2) \
  528. ? ((es & HPC_SLOT_SPEED1) ? HPC_SLOT_SPEED_133 \
  529. : HPC_SLOT_SPEED_66) \
  530. : HPC_SLOT_SPEED_33))
  531. #define SLOT_BUS_MODE(es) ((u8) ((es & HPC_SLOT_BUS_MODE) \
  532. ? HPC_SLOT_BUS_MODE_MISM : HPC_SLOT_BUS_MODE_OK))
  533. //--------------------------------------------------------------------------
  534. // macro for bus info
  535. //---------------------------------------------------------------------------
  536. #define CURRENT_BUS_SPEED(s) ((u8) (s & BUS_SPEED_2) \
  537. ? ((s & BUS_SPEED_1) ? BUS_SPEED_133 : BUS_SPEED_100) \
  538. : ((s & BUS_SPEED_1) ? BUS_SPEED_66 : BUS_SPEED_33))
  539. #define CURRENT_BUS_MODE(s) ((u8) (s & BUS_MODE) ? BUS_MODE_PCIX : BUS_MODE_PCI)
  540. #define READ_BUS_STATUS(s) ((u8) (s->options & BUS_STATUS_AVAILABLE))
  541. #define READ_BUS_MODE(s) ((s->revision & PRGM_MODEL_REV_LEVEL) >= 0x20)
  542. #define SET_BUS_STATUS(s) ((u8) (s->options & BUS_CONTROL_AVAILABLE))
  543. #define READ_SLOT_LATCH(s) ((u8) (s->options & SLOT_LATCH_REGS_SUPPORTED))
  544. //----------------------------------------------------------------------------
  545. // macro for controller info
  546. //----------------------------------------------------------------------------
  547. #define CTLR_WORKING(c) ((u8) ((c & HPC_CTLR_WORKING) \
  548. ? HPC_CTLR_WORKING_YES : HPC_CTLR_WORKING_NO))
  549. #define CTLR_FINISHED(c) ((u8) ((c & HPC_CTLR_FINISHED) \
  550. ? HPC_CTLR_FINISHED_YES : HPC_CTLR_FINISHED_NO))
  551. #define CTLR_RESULT(c) ((u8) ((c & HPC_CTLR_RESULT1) \
  552. ? ((c & HPC_CTLR_RESULT0) ? HPC_CTLR_RESULT_NORESP \
  553. : HPC_CTLR_RESULT_RSVD) \
  554. : ((c & HPC_CTLR_RESULT0) ? HPC_CTLR_RESULT_FAILED \
  555. : HPC_CTLR_RESULT_SUCCESS)))
  556. // command that affect the state machine of HPC
  557. #define NEEDTOCHECK_CMDSTATUS(c) ((c == HPC_SLOT_OFF) || \
  558. (c == HPC_SLOT_ON) || \
  559. (c == HPC_CTLR_RESET) || \
  560. (c == HPC_BUS_33CONVMODE) || \
  561. (c == HPC_BUS_66CONVMODE) || \
  562. (c == HPC_BUS_66PCIXMODE) || \
  563. (c == HPC_BUS_100PCIXMODE) || \
  564. (c == HPC_BUS_133PCIXMODE) || \
  565. (c == HPC_ALLSLOT_OFF) || \
  566. (c == HPC_ALLSLOT_ON))
  567. /* Core part of the driver */
  568. #define ENABLE 1
  569. #define DISABLE 0
  570. #define CARD_INFO 0x07
  571. #define PCIX133 0x07
  572. #define PCIX66 0x05
  573. #define PCI66 0x04
  574. extern struct pci_bus *ibmphp_pci_bus;
  575. /* Variables */
  576. struct pci_func {
  577. struct pci_dev *dev; /* from the OS */
  578. u8 busno;
  579. u8 device;
  580. u8 function;
  581. struct resource_node *io[6];
  582. struct resource_node *mem[6];
  583. struct resource_node *pfmem[6];
  584. struct pci_func *next;
  585. int devices[32]; /* for bridge config */
  586. u8 irq[4]; /* for interrupt config */
  587. u8 bus; /* flag for unconfiguring, to say if PPB */
  588. };
  589. struct slot {
  590. u8 bus;
  591. u8 device;
  592. u8 number;
  593. u8 real_physical_slot_num;
  594. u32 capabilities;
  595. u8 supported_speed;
  596. u8 supported_bus_mode;
  597. u8 flag; /* this is for disable slot and polling */
  598. u8 ctlr_index;
  599. struct hotplug_slot *hotplug_slot;
  600. struct controller *ctrl;
  601. struct pci_func *func;
  602. u8 irq[4];
  603. int bit_mode; /* 0 = 32, 1 = 64 */
  604. struct bus_info *bus_on;
  605. struct list_head ibm_slot_list;
  606. u8 status;
  607. u8 ext_status;
  608. u8 busstatus;
  609. };
  610. struct controller {
  611. struct ebda_hpc_slot *slots;
  612. struct ebda_hpc_bus *buses;
  613. struct pci_dev *ctrl_dev; /* in case where controller is PCI */
  614. u8 starting_slot_num; /* starting and ending slot #'s this ctrl controls*/
  615. u8 ending_slot_num;
  616. u8 revision;
  617. u8 options; /* which options HPC supports */
  618. u8 status;
  619. u8 ctlr_id;
  620. u8 slot_count;
  621. u8 bus_count;
  622. u8 ctlr_relative_id;
  623. u32 irq;
  624. union {
  625. struct isa_ctlr_access isa_ctlr;
  626. struct pci_ctlr_access pci_ctlr;
  627. struct wpeg_i2c_ctlr_access wpeg_ctlr;
  628. } u;
  629. u8 ctlr_type;
  630. struct list_head ebda_hpc_list;
  631. };
  632. /* Functions */
  633. int ibmphp_init_devno(struct slot **); /* This function is called from EBDA, so we need it not be static */
  634. int ibmphp_do_disable_slot(struct slot *slot_cur);
  635. int ibmphp_update_slot_info(struct slot *); /* This function is called from HPC, so we need it to not be be static */
  636. int ibmphp_configure_card(struct pci_func *, u8);
  637. int ibmphp_unconfigure_card(struct slot **, int);
  638. extern struct hotplug_slot_ops ibmphp_hotplug_slot_ops;
  639. #endif //__IBMPHP_H