ieee1394: add definitions for phy packet constants Introduce new macros related to phy packets and use them in ieee1394_core and nodemgr. Also, eliminate some code in hpsb_send_phy_config() which is provided by hpsb_make_phypacket(). Signed-off-by: Stefan Richter --- This patch applies to Jody's for-mm tree plus send-resume-packet patch. ieee1394.h | 19 +++++++++++++++++- ieee1394_core.c | 59 ++++++++++++++++++++++++++------------------------------ nodemgr.c | 3 +- 3 files changed, 48 insertions(+), 33 deletions(-) diff -uprN --ignore-all-space -X linux/Documentation/dontdiff linux-2.6.14.3/drivers/ieee1394-09/ieee1394_core.c linux-2.6.14.3/drivers/ieee1394/ieee1394_core.c --- linux-2.6.14.3/drivers/ieee1394-09/ieee1394_core.c 2005-11-24 23:10:21.000000000 +0100 +++ linux-2.6.14.3/drivers/ieee1394/ieee1394_core.c 2005-11-30 23:41:06.000000000 +0100 @@ -256,10 +256,14 @@ static int check_selfids(struct hpsb_hos esid = (struct ext_selfid *)(sid - 1); while (esid->extended) { - if ((esid->porta == 0x2) || (esid->portb == 0x2) - || (esid->portc == 0x2) || (esid->portd == 0x2) - || (esid->porte == 0x2) || (esid->portf == 0x2) - || (esid->portg == 0x2) || (esid->porth == 0x2)) { + if ((esid->porta == SELFID_PORT_PARENT) || + (esid->portb == SELFID_PORT_PARENT) || + (esid->portc == SELFID_PORT_PARENT) || + (esid->portd == SELFID_PORT_PARENT) || + (esid->porte == SELFID_PORT_PARENT) || + (esid->portf == SELFID_PORT_PARENT) || + (esid->portg == SELFID_PORT_PARENT) || + (esid->porth == SELFID_PORT_PARENT)) { HPSB_INFO("SelfIDs failed root check on " "extended SelfID"); return 0; @@ -268,7 +272,9 @@ static int check_selfids(struct hpsb_hos } sid = (struct selfid *)esid; - if ((sid->port0 == 0x2) || (sid->port1 == 0x2) || (sid->port2 == 0x2)) { + if ((sid->port0 == SELFID_PORT_PARENT) || + (sid->port1 == SELFID_PORT_PARENT) || + (sid->port2 == SELFID_PORT_PARENT)) { HPSB_INFO("SelfIDs failed root check"); return 0; } @@ -303,18 +309,18 @@ static void build_speed_map(struct hpsb_ if (sid->extended) { esid = (struct ext_selfid *)sid; - if (esid->porta == 0x3) cldcnt[n]++; - if (esid->portb == 0x3) cldcnt[n]++; - if (esid->portc == 0x3) cldcnt[n]++; - if (esid->portd == 0x3) cldcnt[n]++; - if (esid->porte == 0x3) cldcnt[n]++; - if (esid->portf == 0x3) cldcnt[n]++; - if (esid->portg == 0x3) cldcnt[n]++; - if (esid->porth == 0x3) cldcnt[n]++; + if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++; } else { - if (sid->port0 == 0x3) cldcnt[n]++; - if (sid->port1 == 0x3) cldcnt[n]++; - if (sid->port2 == 0x3) cldcnt[n]++; + if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++; + if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++; + if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; speedcap[n] = sid->speed; n--; @@ -457,6 +463,7 @@ void hpsb_packet_sent(struct hpsb_host * int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt) { struct hpsb_packet *packet; + quadlet_t d = 0; int retval = 0; if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 || @@ -466,26 +473,16 @@ int hpsb_send_phy_config(struct hpsb_hos return -EINVAL; } - packet = hpsb_alloc_packet(0); - if (!packet) - return -ENOMEM; - - packet->host = host; - packet->header_size = 8; - packet->data_size = 0; - packet->expect_response = 0; - packet->no_waiter = 0; - packet->type = hpsb_raw; - packet->header[0] = 0; if (rootid != -1) - packet->header[0] |= rootid << 24 | 1 << 23; + d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT; if (gapcnt != -1) - packet->header[0] |= gapcnt << 16 | 1 << 22; + d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT; - packet->header[1] = ~packet->header[0]; + packet = hpsb_make_phypacket(host, d); + if (!packet) + return -ENOMEM; packet->generation = get_hpsb_generation(host); - retval = hpsb_send_packet_and_wait(packet); hpsb_free_packet(packet); diff -uprN --ignore-all-space -X linux/Documentation/dontdiff linux-2.6.14.3/drivers/ieee1394-09/ieee1394.h linux-2.6.14.3/drivers/ieee1394/ieee1394.h --- linux-2.6.14.3/drivers/ieee1394-09/ieee1394.h 2005-11-24 23:10:21.000000000 +0100 +++ linux-2.6.14.3/drivers/ieee1394/ieee1394.h 2005-11-30 22:49:33.000000000 +0100 @@ -62,6 +62,7 @@ extern const char *hpsb_speedto_str[]; +/* 1394a cable PHY packets */ #define SELFID_PWRCL_NO_POWER 0x0 #define SELFID_PWRCL_PROVIDE_15W 0x1 #define SELFID_PWRCL_PROVIDE_30W 0x2 @@ -76,8 +77,24 @@ extern const char *hpsb_speedto_str[]; #define SELFID_PORT_NCONN 0x1 #define SELFID_PORT_NONE 0x0 +#define PHYPACKET_LINKON 0x40000000 +#define PHYPACKET_PHYCONFIG_R 0x00800000 +#define PHYPACKET_PHYCONFIG_T 0x00400000 +#define EXTPHYPACKET_TYPE_PING 0x00000000 +#define EXTPHYPACKET_TYPE_REMOTEACCESS_BASE 0x00040000 +#define EXTPHYPACKET_TYPE_REMOTEACCESS_PAGED 0x00140000 +#define EXTPHYPACKET_TYPE_REMOTEREPLY_BASE 0x000C0000 +#define EXTPHYPACKET_TYPE_REMOTEREPLY_PAGED 0x001C0000 +#define EXTPHYPACKET_TYPE_REMOTECOMMAND 0x00200000 +#define EXTPHYPACKET_TYPE_REMOTECONFIRMATION 0x00280000 +#define EXTPHYPACKET_TYPE_RESUME 0x003C0000 -/* 1394a PHY bitmasks */ +#define EXTPHYPACKET_TYPEMASK 0xC0FC0000 + +#define PHYPACKET_PORT_SHIFT 24 +#define PHYPACKET_GAPCOUNT_SHIFT 16 + +/* 1394a PHY register map bitmasks */ #define PHY_00_PHYSICAL_ID 0xFC #define PHY_00_R 0x02 /* Root */ #define PHY_00_PS 0x01 /* Power Status*/ diff -uprN --ignore-all-space -X linux/Documentation/dontdiff linux-2.6.14.3/drivers/ieee1394-09/nodemgr.c linux-2.6.14.3/drivers/ieee1394/nodemgr.c --- linux-2.6.14.3/drivers/ieee1394-09/nodemgr.c 2005-11-30 22:54:26.000000000 +0100 +++ linux-2.6.14.3/drivers/ieee1394/nodemgr.c 2005-11-30 22:53:43.000000000 +0100 @@ -1416,7 +1416,8 @@ static int nodemgr_send_resume_packet(st int ret = 1; packet = hpsb_make_phypacket(host, - 0x003c0000 | NODEID_TO_NODE(host->node_id) << 24); + EXTPHYPACKET_TYPE_RESUME | + NODEID_TO_NODE(host->node_id) << PHYPACKET_PORT_SHIFT); if (packet) { packet->no_waiter = 1; packet->generation = get_hpsb_generation(host);