ibmphp.h 23 KB

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