aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/viodasd.c2
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c22
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.h5
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c31
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.h1
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c63
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h24
-rw-r--r--drivers/net/Makefile3
-rw-r--r--drivers/net/pasemi_mac.c324
-rw-r--r--drivers/net/pasemi_mac.h35
-rw-r--r--drivers/net/pasemi_mac_ethtool.c159
-rw-r--r--drivers/net/ps3_gelic_net.c81
-rw-r--r--drivers/net/ps3_gelic_net.h20
-rw-r--r--drivers/of/base.c26
-rw-r--r--drivers/ps3/ps3-sys-manager.c74
-rw-r--r--drivers/ps3/sys-manager-core.c16
-rw-r--r--drivers/serial/of_serial.c4
17 files changed, 757 insertions, 133 deletions
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 41ca721d2523..ebfe038d859e 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -69,7 +69,7 @@ MODULE_LICENSE("GPL");
69enum { 69enum {
70 PARTITION_SHIFT = 3, 70 PARTITION_SHIFT = 3,
71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS, 71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS,
72 MAX_DISK_NAME = sizeof(((struct gendisk *)0)->disk_name) 72 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name)
73}; 73};
74 74
75static DEFINE_SPINLOCK(viodasd_spinlock); 75static DEFINE_SPINLOCK(viodasd_spinlock);
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index f577daedb630..aa7f7962a9a0 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -74,7 +74,7 @@
74 74
75/** 75/**
76 * buffer_icap_get_status - Get the contents of the status register. 76 * buffer_icap_get_status - Get the contents of the status register.
77 * @base_address: is the base address of the device 77 * @drvdata: a pointer to the drvdata.
78 * 78 *
79 * The status register contains the ICAP status and the done bit. 79 * The status register contains the ICAP status and the done bit.
80 * 80 *
@@ -88,9 +88,9 @@
88 * D1 - Always 1 88 * D1 - Always 1
89 * D0 - Done bit 89 * D0 - Done bit
90 **/ 90 **/
91static inline u32 buffer_icap_get_status(void __iomem *base_address) 91u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata)
92{ 92{
93 return in_be32(base_address + XHI_STATUS_REG_OFFSET); 93 return in_be32(drvdata->base_address + XHI_STATUS_REG_OFFSET);
94} 94}
95 95
96/** 96/**
@@ -117,20 +117,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
117 **/ 117 **/
118static inline bool buffer_icap_busy(void __iomem *base_address) 118static inline bool buffer_icap_busy(void __iomem *base_address)
119{ 119{
120 return (buffer_icap_get_status(base_address) & 1) == XHI_NOT_FINISHED; 120 u32 status = in_be32(base_address + XHI_STATUS_REG_OFFSET);
121} 121 return (status & 1) == XHI_NOT_FINISHED;
122
123/**
124 * buffer_icap_busy - Return true if the icap device is not busy
125 * @base_address: is the base address of the device
126 *
127 * The queries the low order bit of the status register, which
128 * indicates whether the current configuration or readback operation
129 * has completed.
130 **/
131static inline bool buffer_icap_done(void __iomem *base_address)
132{
133 return (buffer_icap_get_status(base_address) & 1) == XHI_FINISHED;
134} 122}
135 123
136/** 124/**
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.h b/drivers/char/xilinx_hwicap/buffer_icap.h
index 03184959fa00..c5b1840906b2 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.h
+++ b/drivers/char/xilinx_hwicap/buffer_icap.h
@@ -44,8 +44,6 @@
44#include <asm/io.h> 44#include <asm/io.h>
45#include "xilinx_hwicap.h" 45#include "xilinx_hwicap.h"
46 46
47void buffer_icap_reset(struct hwicap_drvdata *drvdata);
48
49/* Loads a partial bitstream from system memory. */ 47/* Loads a partial bitstream from system memory. */
50int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, 48int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
51 u32 Size); 49 u32 Size);
@@ -54,4 +52,7 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
54int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data, 52int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data,
55 u32 Size); 53 u32 Size);
56 54
55u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata);
56void buffer_icap_reset(struct hwicap_drvdata *drvdata);
57
57#endif 58#endif
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 6f45dbd47125..776b50528478 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -78,13 +78,6 @@
78#define XHI_CR_READ_MASK 0x00000002 /* Read from ICAP to FIFO */ 78#define XHI_CR_READ_MASK 0x00000002 /* Read from ICAP to FIFO */
79#define XHI_CR_WRITE_MASK 0x00000001 /* Write from FIFO to ICAP */ 79#define XHI_CR_WRITE_MASK 0x00000001 /* Write from FIFO to ICAP */
80 80
81/* Status Register (SR) */
82#define XHI_SR_CFGERR_N_MASK 0x00000100 /* Config Error Mask */
83#define XHI_SR_DALIGN_MASK 0x00000080 /* Data Alignment Mask */
84#define XHI_SR_RIP_MASK 0x00000040 /* Read back Mask */
85#define XHI_SR_IN_ABORT_N_MASK 0x00000020 /* Select Map Abort Mask */
86#define XHI_SR_DONE_MASK 0x00000001 /* Done bit Mask */
87
88 81
89#define XHI_WFO_MAX_VACANCY 1024 /* Max Write FIFO Vacancy, in words */ 82#define XHI_WFO_MAX_VACANCY 1024 /* Max Write FIFO Vacancy, in words */
90#define XHI_RFO_MAX_OCCUPANCY 256 /* Max Read FIFO Occupancy, in words */ 83#define XHI_RFO_MAX_OCCUPANCY 256 /* Max Read FIFO Occupancy, in words */
@@ -152,13 +145,35 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
152} 145}
153 146
154/** 147/**
148 * fifo_icap_get_status - Get the contents of the status register.
149 * @drvdata: a pointer to the drvdata.
150 *
151 * The status register contains the ICAP status and the done bit.
152 *
153 * D8 - cfgerr
154 * D7 - dalign
155 * D6 - rip
156 * D5 - in_abort_l
157 * D4 - Always 1
158 * D3 - Always 1
159 * D2 - Always 1
160 * D1 - Always 1
161 * D0 - Done bit
162 **/
163u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata)
164{
165 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
166 dev_dbg(drvdata->dev, "Getting status = %x\n", status);
167 return status;
168}
169
170/**
155 * fifo_icap_busy - Return true if the ICAP is still processing a transaction. 171 * fifo_icap_busy - Return true if the ICAP is still processing a transaction.
156 * @drvdata: a pointer to the drvdata. 172 * @drvdata: a pointer to the drvdata.
157 **/ 173 **/
158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata) 174static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
159{ 175{
160 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET); 176 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
161 dev_dbg(drvdata->dev, "Getting status = %x\n", status);
162 return (status & XHI_SR_DONE_MASK) ? 0 : 1; 177 return (status & XHI_SR_DONE_MASK) ? 0 : 1;
163} 178}
164 179
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.h b/drivers/char/xilinx_hwicap/fifo_icap.h
index 4d3068dd0405..ffabd3ba2bd8 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.h
+++ b/drivers/char/xilinx_hwicap/fifo_icap.h
@@ -56,6 +56,7 @@ int fifo_icap_set_configuration(
56 u32 *FrameBuffer, 56 u32 *FrameBuffer,
57 u32 NumWords); 57 u32 NumWords);
58 58
59u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata);
59void fifo_icap_reset(struct hwicap_drvdata *drvdata); 60void fifo_icap_reset(struct hwicap_drvdata *drvdata);
60void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata); 61void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata);
61 62
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 2284fa2a5a57..016f90567a52 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -36,7 +36,7 @@
36 *****************************************************************************/ 36 *****************************************************************************/
37 37
38/* 38/*
39 * This is the code behind /dev/xilinx_icap -- it allows a user-space 39 * This is the code behind /dev/icap* -- it allows a user-space
40 * application to use the Xilinx ICAP subsystem. 40 * application to use the Xilinx ICAP subsystem.
41 * 41 *
42 * The following operations are possible: 42 * The following operations are possible:
@@ -67,7 +67,7 @@
67 * user-space application code that uses this device. The simplest 67 * user-space application code that uses this device. The simplest
68 * way to use this interface is simply: 68 * way to use this interface is simply:
69 * 69 *
70 * cp foo.bit /dev/xilinx_icap 70 * cp foo.bit /dev/icap0
71 * 71 *
72 * Note that unless foo.bit is an appropriately constructed partial 72 * Note that unless foo.bit is an appropriately constructed partial
73 * bitstream, this has a high likelyhood of overwriting the design 73 * bitstream, this has a high likelyhood of overwriting the design
@@ -105,18 +105,14 @@
105#include "buffer_icap.h" 105#include "buffer_icap.h"
106#include "fifo_icap.h" 106#include "fifo_icap.h"
107 107
108#define DRIVER_NAME "xilinx_icap" 108#define DRIVER_NAME "icap"
109 109
110#define HWICAP_REGS (0x10000) 110#define HWICAP_REGS (0x10000)
111 111
112/* dynamically allocate device number */ 112#define XHWICAP_MAJOR 259
113static int xhwicap_major; 113#define XHWICAP_MINOR 0
114static int xhwicap_minor;
115#define HWICAP_DEVICES 1 114#define HWICAP_DEVICES 1
116 115
117module_param(xhwicap_major, int, S_IRUGO);
118module_param(xhwicap_minor, int, S_IRUGO);
119
120/* An array, which is set to true when the device is registered. */ 116/* An array, which is set to true when the device is registered. */
121static bool probed_devices[HWICAP_DEVICES]; 117static bool probed_devices[HWICAP_DEVICES];
122static struct mutex icap_sem; 118static struct mutex icap_sem;
@@ -250,8 +246,26 @@ static int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
250 * Create the data to be written to the ICAP. 246 * Create the data to be written to the ICAP.
251 */ 247 */
252 buffer[index++] = XHI_DUMMY_PACKET; 248 buffer[index++] = XHI_DUMMY_PACKET;
249 buffer[index++] = XHI_NOOP_PACKET;
253 buffer[index++] = XHI_SYNC_PACKET; 250 buffer[index++] = XHI_SYNC_PACKET;
254 buffer[index++] = XHI_NOOP_PACKET; 251 buffer[index++] = XHI_NOOP_PACKET;
252 buffer[index++] = XHI_NOOP_PACKET;
253
254 /*
255 * Write the data to the FIFO and initiate the transfer of data present
256 * in the FIFO to the ICAP device.
257 */
258 status = drvdata->config->set_configuration(drvdata,
259 &buffer[0], index);
260 if (status)
261 return status;
262
263 /* If the syncword was not found, then we need to start over. */
264 status = drvdata->config->get_status(drvdata);
265 if ((status & XHI_SR_DALIGN_MASK) != XHI_SR_DALIGN_MASK)
266 return -EIO;
267
268 index = 0;
255 buffer[index++] = hwicap_type_1_read(reg) | 1; 269 buffer[index++] = hwicap_type_1_read(reg) | 1;
256 buffer[index++] = XHI_NOOP_PACKET; 270 buffer[index++] = XHI_NOOP_PACKET;
257 buffer[index++] = XHI_NOOP_PACKET; 271 buffer[index++] = XHI_NOOP_PACKET;
@@ -587,7 +601,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
587 probed_devices[id] = 1; 601 probed_devices[id] = 1;
588 mutex_unlock(&icap_sem); 602 mutex_unlock(&icap_sem);
589 603
590 devt = MKDEV(xhwicap_major, xhwicap_minor + id); 604 devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR + id);
591 605
592 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); 606 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
593 if (!drvdata) { 607 if (!drvdata) {
@@ -664,12 +678,14 @@ static int __devinit hwicap_setup(struct device *dev, int id,
664static struct hwicap_driver_config buffer_icap_config = { 678static struct hwicap_driver_config buffer_icap_config = {
665 .get_configuration = buffer_icap_get_configuration, 679 .get_configuration = buffer_icap_get_configuration,
666 .set_configuration = buffer_icap_set_configuration, 680 .set_configuration = buffer_icap_set_configuration,
681 .get_status = buffer_icap_get_status,
667 .reset = buffer_icap_reset, 682 .reset = buffer_icap_reset,
668}; 683};
669 684
670static struct hwicap_driver_config fifo_icap_config = { 685static struct hwicap_driver_config fifo_icap_config = {
671 .get_configuration = fifo_icap_get_configuration, 686 .get_configuration = fifo_icap_get_configuration,
672 .set_configuration = fifo_icap_set_configuration, 687 .set_configuration = fifo_icap_set_configuration,
688 .get_status = fifo_icap_get_status,
673 .reset = fifo_icap_reset, 689 .reset = fifo_icap_reset,
674}; 690};
675 691
@@ -690,7 +706,7 @@ static int __devexit hwicap_remove(struct device *dev)
690 dev_set_drvdata(dev, NULL); 706 dev_set_drvdata(dev, NULL);
691 707
692 mutex_lock(&icap_sem); 708 mutex_lock(&icap_sem);
693 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0; 709 probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0;
694 mutex_unlock(&icap_sem); 710 mutex_unlock(&icap_sem);
695 return 0; /* success */ 711 return 0; /* success */
696} 712}
@@ -830,23 +846,12 @@ static int __init hwicap_module_init(void)
830 icap_class = class_create(THIS_MODULE, "xilinx_config"); 846 icap_class = class_create(THIS_MODULE, "xilinx_config");
831 mutex_init(&icap_sem); 847 mutex_init(&icap_sem);
832 848
833 if (xhwicap_major) { 849 devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
834 devt = MKDEV(xhwicap_major, xhwicap_minor); 850 retval = register_chrdev_region(devt,
835 retval = register_chrdev_region( 851 HWICAP_DEVICES,
836 devt, 852 DRIVER_NAME);
837 HWICAP_DEVICES, 853 if (retval < 0)
838 DRIVER_NAME); 854 return retval;
839 if (retval < 0)
840 return retval;
841 } else {
842 retval = alloc_chrdev_region(&devt,
843 xhwicap_minor,
844 HWICAP_DEVICES,
845 DRIVER_NAME);
846 if (retval < 0)
847 return retval;
848 xhwicap_major = MAJOR(devt);
849 }
850 855
851 retval = platform_driver_register(&hwicap_platform_driver); 856 retval = platform_driver_register(&hwicap_platform_driver);
852 857
@@ -871,7 +876,7 @@ static int __init hwicap_module_init(void)
871 876
872static void __exit hwicap_module_cleanup(void) 877static void __exit hwicap_module_cleanup(void)
873{ 878{
874 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor); 879 dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
875 880
876 class_destroy(icap_class); 881 class_destroy(icap_class);
877 882
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index 405fee7e189b..1f9c8b082dbe 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -65,10 +65,27 @@ struct hwicap_drvdata {
65}; 65};
66 66
67struct hwicap_driver_config { 67struct hwicap_driver_config {
68 /* Read configuration data given by size into the data buffer.
69 Return 0 if successful. */
68 int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data, 70 int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
69 u32 size); 71 u32 size);
72 /* Write configuration data given by size from the data buffer.
73 Return 0 if successful. */
70 int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data, 74 int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
71 u32 size); 75 u32 size);
76 /* Get the status register, bit pattern given by:
77 * D8 - 0 = configuration error
78 * D7 - 1 = alignment found
79 * D6 - 1 = readback in progress
80 * D5 - 0 = abort in progress
81 * D4 - Always 1
82 * D3 - Always 1
83 * D2 - Always 1
84 * D1 - Always 1
85 * D0 - 1 = operation completed
86 */
87 u32 (*get_status)(struct hwicap_drvdata *drvdata);
88 /* Reset the hw */
72 void (*reset)(struct hwicap_drvdata *drvdata); 89 void (*reset)(struct hwicap_drvdata *drvdata);
73}; 90};
74 91
@@ -163,6 +180,13 @@ struct config_registers {
163/* Constant to use for CRC check when CRC has been disabled */ 180/* Constant to use for CRC check when CRC has been disabled */
164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL 181#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
165 182
183/* Meanings of the bits returned by get_status */
184#define XHI_SR_CFGERR_N_MASK 0x00000100 /* Config Error Mask */
185#define XHI_SR_DALIGN_MASK 0x00000080 /* Data Alignment Mask */
186#define XHI_SR_RIP_MASK 0x00000040 /* Read back Mask */
187#define XHI_SR_IN_ABORT_N_MASK 0x00000020 /* Select Map Abort Mask */
188#define XHI_SR_DONE_MASK 0x00000001 /* Done bit Mask */
189
166/** 190/**
167 * hwicap_type_1_read - Generates a Type 1 read packet header. 191 * hwicap_type_1_read - Generates a Type 1 read packet header.
168 * @reg: is the address of the register to be read back. 192 * @reg: is the address of the register to be read back.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 3b1ea321dc05..4b442739e7bf 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -218,7 +218,8 @@ obj-$(CONFIG_SMC911X) += smc911x.o
218obj-$(CONFIG_BFIN_MAC) += bfin_mac.o 218obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
219obj-$(CONFIG_DM9000) += dm9000.o 219obj-$(CONFIG_DM9000) += dm9000.o
220obj-$(CONFIG_FEC_8XX) += fec_8xx/ 220obj-$(CONFIG_FEC_8XX) += fec_8xx/
221obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o 221obj-$(CONFIG_PASEMI_MAC) += pasemi_mac_driver.o
222pasemi_mac_driver-objs := pasemi_mac.o pasemi_mac_ethtool.o
222obj-$(CONFIG_MLX4_CORE) += mlx4/ 223obj-$(CONFIG_MLX4_CORE) += mlx4/
223obj-$(CONFIG_ENC28J60) += enc28j60.o 224obj-$(CONFIG_ENC28J60) += enc28j60.o
224 225
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 2e39e0285d8f..c50f0f4de6d8 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -55,15 +55,10 @@
55 * - Multiqueue RX/TX 55 * - Multiqueue RX/TX
56 */ 56 */
57 57
58
59/* Must be a power of two */
60#define RX_RING_SIZE 2048
61#define TX_RING_SIZE 4096
62
63#define LRO_MAX_AGGR 64 58#define LRO_MAX_AGGR 64
64 59
65#define PE_MIN_MTU 64 60#define PE_MIN_MTU 64
66#define PE_MAX_MTU 1500 61#define PE_MAX_MTU 9000
67#define PE_DEF_MTU ETH_DATA_LEN 62#define PE_DEF_MTU ETH_DATA_LEN
68 63
69#define DEFAULT_MSG_ENABLE \ 64#define DEFAULT_MSG_ENABLE \
@@ -76,16 +71,6 @@
76 NETIF_MSG_RX_ERR | \ 71 NETIF_MSG_RX_ERR | \
77 NETIF_MSG_TX_ERR) 72 NETIF_MSG_TX_ERR)
78 73
79#define TX_DESC(tx, num) ((tx)->chan.ring_virt[(num) & (TX_RING_SIZE-1)])
80#define TX_DESC_INFO(tx, num) ((tx)->ring_info[(num) & (TX_RING_SIZE-1)])
81#define RX_DESC(rx, num) ((rx)->chan.ring_virt[(num) & (RX_RING_SIZE-1)])
82#define RX_DESC_INFO(rx, num) ((rx)->ring_info[(num) & (RX_RING_SIZE-1)])
83#define RX_BUFF(rx, num) ((rx)->buffers[(num) & (RX_RING_SIZE-1)])
84
85#define RING_USED(ring) (((ring)->next_to_fill - (ring)->next_to_clean) \
86 & ((ring)->size - 1))
87#define RING_AVAIL(ring) ((ring->size) - RING_USED(ring))
88
89MODULE_LICENSE("GPL"); 74MODULE_LICENSE("GPL");
90MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); 75MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
91MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver"); 76MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver");
@@ -94,6 +79,8 @@ static int debug = -1; /* -1 == use DEFAULT_MSG_ENABLE as value */
94module_param(debug, int, 0); 79module_param(debug, int, 0);
95MODULE_PARM_DESC(debug, "PA Semi MAC bitmapped debugging message enable value"); 80MODULE_PARM_DESC(debug, "PA Semi MAC bitmapped debugging message enable value");
96 81
82extern const struct ethtool_ops pasemi_mac_ethtool_ops;
83
97static int translation_enabled(void) 84static int translation_enabled(void)
98{ 85{
99#if defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE) 86#if defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE)
@@ -322,6 +309,103 @@ static int pasemi_mac_unmap_tx_skb(struct pasemi_mac *mac,
322 return (nfrags + 3) & ~1; 309 return (nfrags + 3) & ~1;
323} 310}
324 311
312static struct pasemi_mac_csring *pasemi_mac_setup_csring(struct pasemi_mac *mac)
313{
314 struct pasemi_mac_csring *ring;
315 u32 val;
316 unsigned int cfg;
317 int chno;
318
319 ring = pasemi_dma_alloc_chan(TXCHAN, sizeof(struct pasemi_mac_csring),
320 offsetof(struct pasemi_mac_csring, chan));
321
322 if (!ring) {
323 dev_err(&mac->pdev->dev, "Can't allocate checksum channel\n");
324 goto out_chan;
325 }
326
327 chno = ring->chan.chno;
328
329 ring->size = CS_RING_SIZE;
330 ring->next_to_fill = 0;
331
332 /* Allocate descriptors */
333 if (pasemi_dma_alloc_ring(&ring->chan, CS_RING_SIZE))
334 goto out_ring_desc;
335
336 write_dma_reg(PAS_DMA_TXCHAN_BASEL(chno),
337 PAS_DMA_TXCHAN_BASEL_BRBL(ring->chan.ring_dma));
338 val = PAS_DMA_TXCHAN_BASEU_BRBH(ring->chan.ring_dma >> 32);
339 val |= PAS_DMA_TXCHAN_BASEU_SIZ(CS_RING_SIZE >> 3);
340
341 write_dma_reg(PAS_DMA_TXCHAN_BASEU(chno), val);
342
343 ring->events[0] = pasemi_dma_alloc_flag();
344 ring->events[1] = pasemi_dma_alloc_flag();
345 if (ring->events[0] < 0 || ring->events[1] < 0)
346 goto out_flags;
347
348 pasemi_dma_clear_flag(ring->events[0]);
349 pasemi_dma_clear_flag(ring->events[1]);
350
351 ring->fun = pasemi_dma_alloc_fun();
352 if (ring->fun < 0)
353 goto out_fun;
354
355 cfg = PAS_DMA_TXCHAN_CFG_TY_FUNC | PAS_DMA_TXCHAN_CFG_UP |
356 PAS_DMA_TXCHAN_CFG_TATTR(ring->fun) |
357 PAS_DMA_TXCHAN_CFG_LPSQ | PAS_DMA_TXCHAN_CFG_LPDQ;
358
359 if (translation_enabled())
360 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR;
361
362 write_dma_reg(PAS_DMA_TXCHAN_CFG(chno), cfg);
363
364 /* enable channel */
365 pasemi_dma_start_chan(&ring->chan, PAS_DMA_TXCHAN_TCMDSTA_SZ |
366 PAS_DMA_TXCHAN_TCMDSTA_DB |
367 PAS_DMA_TXCHAN_TCMDSTA_DE |
368 PAS_DMA_TXCHAN_TCMDSTA_DA);
369
370 return ring;
371
372out_fun:
373out_flags:
374 if (ring->events[0] >= 0)
375 pasemi_dma_free_flag(ring->events[0]);
376 if (ring->events[1] >= 0)
377 pasemi_dma_free_flag(ring->events[1]);
378 pasemi_dma_free_ring(&ring->chan);
379out_ring_desc:
380 pasemi_dma_free_chan(&ring->chan);
381out_chan:
382
383 return NULL;
384}
385
386static void pasemi_mac_setup_csrings(struct pasemi_mac *mac)
387{
388 int i;
389 mac->cs[0] = pasemi_mac_setup_csring(mac);
390 if (mac->type == MAC_TYPE_XAUI)
391 mac->cs[1] = pasemi_mac_setup_csring(mac);
392 else
393 mac->cs[1] = 0;
394
395 for (i = 0; i < MAX_CS; i++)
396 if (mac->cs[i])
397 mac->num_cs++;
398}
399
400static void pasemi_mac_free_csring(struct pasemi_mac_csring *csring)
401{
402 pasemi_dma_stop_chan(&csring->chan);
403 pasemi_dma_free_flag(csring->events[0]);
404 pasemi_dma_free_flag(csring->events[1]);
405 pasemi_dma_free_ring(&csring->chan);
406 pasemi_dma_free_chan(&csring->chan);
407}
408
325static int pasemi_mac_setup_rx_resources(const struct net_device *dev) 409static int pasemi_mac_setup_rx_resources(const struct net_device *dev)
326{ 410{
327 struct pasemi_mac_rxring *ring; 411 struct pasemi_mac_rxring *ring;
@@ -445,7 +529,7 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev)
445 cfg = PAS_DMA_TXCHAN_CFG_TY_IFACE | 529 cfg = PAS_DMA_TXCHAN_CFG_TY_IFACE |
446 PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) | 530 PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) |
447 PAS_DMA_TXCHAN_CFG_UP | 531 PAS_DMA_TXCHAN_CFG_UP |
448 PAS_DMA_TXCHAN_CFG_WT(2); 532 PAS_DMA_TXCHAN_CFG_WT(4);
449 533
450 if (translation_enabled()) 534 if (translation_enabled())
451 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR; 535 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR;
@@ -810,13 +894,21 @@ restart:
810 u64 mactx = TX_DESC(txring, i); 894 u64 mactx = TX_DESC(txring, i);
811 struct sk_buff *skb; 895 struct sk_buff *skb;
812 896
813 skb = TX_DESC_INFO(txring, i+1).skb;
814 nr_frags = TX_DESC_INFO(txring, i).dma;
815
816 if ((mactx & XCT_MACTX_E) || 897 if ((mactx & XCT_MACTX_E) ||
817 (*chan->status & PAS_STATUS_ERROR)) 898 (*chan->status & PAS_STATUS_ERROR))
818 pasemi_mac_tx_error(mac, mactx); 899 pasemi_mac_tx_error(mac, mactx);
819 900
901 /* Skip over control descriptors */
902 if (!(mactx & XCT_MACTX_LLEN_M)) {
903 TX_DESC(txring, i) = 0;
904 TX_DESC(txring, i+1) = 0;
905 buf_count = 2;
906 continue;
907 }
908
909 skb = TX_DESC_INFO(txring, i+1).skb;
910 nr_frags = TX_DESC_INFO(txring, i).dma;
911
820 if (unlikely(mactx & XCT_MACTX_O)) 912 if (unlikely(mactx & XCT_MACTX_O))
821 /* Not yet transmitted */ 913 /* Not yet transmitted */
822 break; 914 break;
@@ -1041,13 +1133,7 @@ static int pasemi_mac_open(struct net_device *dev)
1041{ 1133{
1042 struct pasemi_mac *mac = netdev_priv(dev); 1134 struct pasemi_mac *mac = netdev_priv(dev);
1043 unsigned int flags; 1135 unsigned int flags;
1044 int ret; 1136 int i, ret;
1045
1046 /* enable rx section */
1047 write_dma_reg(PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN);
1048
1049 /* enable tx section */
1050 write_dma_reg(PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN);
1051 1137
1052 flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) | 1138 flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) |
1053 PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) | 1139 PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) |
@@ -1064,6 +1150,16 @@ static int pasemi_mac_open(struct net_device *dev)
1064 if (!mac->tx) 1150 if (!mac->tx)
1065 goto out_tx_ring; 1151 goto out_tx_ring;
1066 1152
1153 if (dev->mtu > 1500) {
1154 pasemi_mac_setup_csrings(mac);
1155 if (!mac->num_cs)
1156 goto out_tx_ring;
1157 }
1158
1159 /* Zero out rmon counters */
1160 for (i = 0; i < 32; i++)
1161 write_mac_reg(mac, PAS_MAC_RMON(i), 0);
1162
1067 /* 0x3ff with 33MHz clock is about 31us */ 1163 /* 0x3ff with 33MHz clock is about 31us */
1068 write_iob_reg(PAS_IOB_DMA_COM_TIMEOUTCFG, 1164 write_iob_reg(PAS_IOB_DMA_COM_TIMEOUTCFG,
1069 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0x3ff)); 1165 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0x3ff));
@@ -1247,7 +1343,7 @@ static int pasemi_mac_close(struct net_device *dev)
1247{ 1343{
1248 struct pasemi_mac *mac = netdev_priv(dev); 1344 struct pasemi_mac *mac = netdev_priv(dev);
1249 unsigned int sta; 1345 unsigned int sta;
1250 int rxch, txch; 1346 int rxch, txch, i;
1251 1347
1252 rxch = rx_ring(mac)->chan.chno; 1348 rxch = rx_ring(mac)->chan.chno;
1253 txch = tx_ring(mac)->chan.chno; 1349 txch = tx_ring(mac)->chan.chno;
@@ -1292,6 +1388,9 @@ static int pasemi_mac_close(struct net_device *dev)
1292 free_irq(mac->tx->chan.irq, mac->tx); 1388 free_irq(mac->tx->chan.irq, mac->tx);
1293 free_irq(mac->rx->chan.irq, mac->rx); 1389 free_irq(mac->rx->chan.irq, mac->rx);
1294 1390
1391 for (i = 0; i < mac->num_cs; i++)
1392 pasemi_mac_free_csring(mac->cs[i]);
1393
1295 /* Free resources */ 1394 /* Free resources */
1296 pasemi_mac_free_rx_resources(mac); 1395 pasemi_mac_free_rx_resources(mac);
1297 pasemi_mac_free_tx_resources(mac); 1396 pasemi_mac_free_tx_resources(mac);
@@ -1299,35 +1398,113 @@ static int pasemi_mac_close(struct net_device *dev)
1299 return 0; 1398 return 0;
1300} 1399}
1301 1400
1401static void pasemi_mac_queue_csdesc(const struct sk_buff *skb,
1402 const dma_addr_t *map,
1403 const unsigned int *map_size,
1404 struct pasemi_mac_txring *txring,
1405 struct pasemi_mac_csring *csring)
1406{
1407 u64 fund;
1408 dma_addr_t cs_dest;
1409 const int nh_off = skb_network_offset(skb);
1410 const int nh_len = skb_network_header_len(skb);
1411 const int nfrags = skb_shinfo(skb)->nr_frags;
1412 int cs_size, i, fill, hdr, cpyhdr, evt;
1413 dma_addr_t csdma;
1414
1415 fund = XCT_FUN_ST | XCT_FUN_RR_8BRES |
1416 XCT_FUN_O | XCT_FUN_FUN(csring->fun) |
1417 XCT_FUN_CRM_SIG | XCT_FUN_LLEN(skb->len - nh_off) |
1418 XCT_FUN_SHL(nh_len >> 2) | XCT_FUN_SE;
1419
1420 switch (ip_hdr(skb)->protocol) {
1421 case IPPROTO_TCP:
1422 fund |= XCT_FUN_SIG_TCP4;
1423 /* TCP checksum is 16 bytes into the header */
1424 cs_dest = map[0] + skb_transport_offset(skb) + 16;
1425 break;
1426 case IPPROTO_UDP:
1427 fund |= XCT_FUN_SIG_UDP4;
1428 /* UDP checksum is 6 bytes into the header */
1429 cs_dest = map[0] + skb_transport_offset(skb) + 6;
1430 break;
1431 default:
1432 BUG();
1433 }
1434
1435 /* Do the checksum offloaded */
1436 fill = csring->next_to_fill;
1437 hdr = fill;
1438
1439 CS_DESC(csring, fill++) = fund;
1440 /* Room for 8BRES. Checksum result is really 2 bytes into it */
1441 csdma = csring->chan.ring_dma + (fill & (CS_RING_SIZE-1)) * 8 + 2;
1442 CS_DESC(csring, fill++) = 0;
1443
1444 CS_DESC(csring, fill) = XCT_PTR_LEN(map_size[0]-nh_off) | XCT_PTR_ADDR(map[0]+nh_off);
1445 for (i = 1; i <= nfrags; i++)
1446 CS_DESC(csring, fill+i) = XCT_PTR_LEN(map_size[i]) | XCT_PTR_ADDR(map[i]);
1447
1448 fill += i;
1449 if (fill & 1)
1450 fill++;
1451
1452 /* Copy the result into the TCP packet */
1453 cpyhdr = fill;
1454 CS_DESC(csring, fill++) = XCT_FUN_O | XCT_FUN_FUN(csring->fun) |
1455 XCT_FUN_LLEN(2) | XCT_FUN_SE;
1456 CS_DESC(csring, fill++) = XCT_PTR_LEN(2) | XCT_PTR_ADDR(cs_dest) | XCT_PTR_T;
1457 CS_DESC(csring, fill++) = XCT_PTR_LEN(2) | XCT_PTR_ADDR(csdma);
1458 fill++;
1459
1460 evt = !csring->last_event;
1461 csring->last_event = evt;
1462
1463 /* Event handshaking with MAC TX */
1464 CS_DESC(csring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1465 CTRL_CMD_ETYPE_SET | CTRL_CMD_REG(csring->events[evt]);
1466 CS_DESC(csring, fill++) = 0;
1467 CS_DESC(csring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1468 CTRL_CMD_ETYPE_WCLR | CTRL_CMD_REG(csring->events[!evt]);
1469 CS_DESC(csring, fill++) = 0;
1470 csring->next_to_fill = fill & (CS_RING_SIZE-1);
1471
1472 cs_size = fill - hdr;
1473 write_dma_reg(PAS_DMA_TXCHAN_INCR(csring->chan.chno), (cs_size) >> 1);
1474
1475 /* TX-side event handshaking */
1476 fill = txring->next_to_fill;
1477 TX_DESC(txring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1478 CTRL_CMD_ETYPE_WSET | CTRL_CMD_REG(csring->events[evt]);
1479 TX_DESC(txring, fill++) = 0;
1480 TX_DESC(txring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1481 CTRL_CMD_ETYPE_CLR | CTRL_CMD_REG(csring->events[!evt]);
1482 TX_DESC(txring, fill++) = 0;
1483 txring->next_to_fill = fill;
1484
1485 write_dma_reg(PAS_DMA_TXCHAN_INCR(txring->chan.chno), 2);
1486
1487 return;
1488}
1489
1302static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev) 1490static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1303{ 1491{
1304 struct pasemi_mac *mac = netdev_priv(dev); 1492 struct pasemi_mac * const mac = netdev_priv(dev);
1305 struct pasemi_mac_txring *txring; 1493 struct pasemi_mac_txring * const txring = tx_ring(mac);
1306 u64 dflags, mactx; 1494 struct pasemi_mac_csring *csring;
1495 u64 dflags = 0;
1496 u64 mactx;
1307 dma_addr_t map[MAX_SKB_FRAGS+1]; 1497 dma_addr_t map[MAX_SKB_FRAGS+1];
1308 unsigned int map_size[MAX_SKB_FRAGS+1]; 1498 unsigned int map_size[MAX_SKB_FRAGS+1];
1309 unsigned long flags; 1499 unsigned long flags;
1310 int i, nfrags; 1500 int i, nfrags;
1311 int fill; 1501 int fill;
1502 const int nh_off = skb_network_offset(skb);
1503 const int nh_len = skb_network_header_len(skb);
1312 1504
1313 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_CRC_PAD; 1505 prefetch(&txring->ring_info);
1314
1315 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1316 const unsigned char *nh = skb_network_header(skb);
1317 1506
1318 switch (ip_hdr(skb)->protocol) { 1507 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_CRC_PAD;
1319 case IPPROTO_TCP:
1320 dflags |= XCT_MACTX_CSUM_TCP;
1321 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
1322 dflags |= XCT_MACTX_IPO(nh - skb->data);
1323 break;
1324 case IPPROTO_UDP:
1325 dflags |= XCT_MACTX_CSUM_UDP;
1326 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
1327 dflags |= XCT_MACTX_IPO(nh - skb->data);
1328 break;
1329 }
1330 }
1331 1508
1332 nfrags = skb_shinfo(skb)->nr_frags; 1509 nfrags = skb_shinfo(skb)->nr_frags;
1333 1510
@@ -1350,24 +1527,46 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1350 } 1527 }
1351 } 1528 }
1352 1529
1353 mactx = dflags | XCT_MACTX_LLEN(skb->len); 1530 if (skb->ip_summed == CHECKSUM_PARTIAL && skb->len <= 1540) {
1531 switch (ip_hdr(skb)->protocol) {
1532 case IPPROTO_TCP:
1533 dflags |= XCT_MACTX_CSUM_TCP;
1534 dflags |= XCT_MACTX_IPH(nh_len >> 2);
1535 dflags |= XCT_MACTX_IPO(nh_off);
1536 break;
1537 case IPPROTO_UDP:
1538 dflags |= XCT_MACTX_CSUM_UDP;
1539 dflags |= XCT_MACTX_IPH(nh_len >> 2);
1540 dflags |= XCT_MACTX_IPO(nh_off);
1541 break;
1542 default:
1543 WARN_ON(1);
1544 }
1545 }
1354 1546
1355 txring = tx_ring(mac); 1547 mactx = dflags | XCT_MACTX_LLEN(skb->len);
1356 1548
1357 spin_lock_irqsave(&txring->lock, flags); 1549 spin_lock_irqsave(&txring->lock, flags);
1358 1550
1359 fill = txring->next_to_fill;
1360
1361 /* Avoid stepping on the same cache line that the DMA controller 1551 /* Avoid stepping on the same cache line that the DMA controller
1362 * is currently about to send, so leave at least 8 words available. 1552 * is currently about to send, so leave at least 8 words available.
1363 * Total free space needed is mactx + fragments + 8 1553 * Total free space needed is mactx + fragments + 8
1364 */ 1554 */
1365 if (RING_AVAIL(txring) < nfrags + 10) { 1555 if (RING_AVAIL(txring) < nfrags + 14) {
1366 /* no room -- stop the queue and wait for tx intr */ 1556 /* no room -- stop the queue and wait for tx intr */
1367 netif_stop_queue(dev); 1557 netif_stop_queue(dev);
1368 goto out_err; 1558 goto out_err;
1369 } 1559 }
1370 1560
1561 /* Queue up checksum + event descriptors, if needed */
1562 if (mac->num_cs && skb->ip_summed == CHECKSUM_PARTIAL && skb->len > 1540) {
1563 csring = mac->cs[mac->last_cs];
1564 mac->last_cs = (mac->last_cs + 1) % mac->num_cs;
1565
1566 pasemi_mac_queue_csdesc(skb, map, map_size, txring, csring);
1567 }
1568
1569 fill = txring->next_to_fill;
1371 TX_DESC(txring, fill) = mactx; 1570 TX_DESC(txring, fill) = mactx;
1372 TX_DESC_INFO(txring, fill).dma = nfrags; 1571 TX_DESC_INFO(txring, fill).dma = nfrags;
1373 fill++; 1572 fill++;
@@ -1445,8 +1644,9 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1445{ 1644{
1446 struct pasemi_mac *mac = netdev_priv(dev); 1645 struct pasemi_mac *mac = netdev_priv(dev);
1447 unsigned int reg; 1646 unsigned int reg;
1448 unsigned int rcmdsta; 1647 unsigned int rcmdsta = 0;
1449 int running; 1648 int running;
1649 int ret = 0;
1450 1650
1451 if (new_mtu < PE_MIN_MTU || new_mtu > PE_MAX_MTU) 1651 if (new_mtu < PE_MIN_MTU || new_mtu > PE_MAX_MTU)
1452 return -EINVAL; 1652 return -EINVAL;
@@ -1468,6 +1668,16 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1468 pasemi_mac_pause_rxint(mac); 1668 pasemi_mac_pause_rxint(mac);
1469 pasemi_mac_clean_rx(rx_ring(mac), RX_RING_SIZE); 1669 pasemi_mac_clean_rx(rx_ring(mac), RX_RING_SIZE);
1470 pasemi_mac_free_rx_buffers(mac); 1670 pasemi_mac_free_rx_buffers(mac);
1671
1672 }
1673
1674 /* Setup checksum channels if large MTU and none already allocated */
1675 if (new_mtu > 1500 && !mac->num_cs) {
1676 pasemi_mac_setup_csrings(mac);
1677 if (!mac->num_cs) {
1678 ret = -ENOMEM;
1679 goto out;
1680 }
1471 } 1681 }
1472 1682
1473 /* Change maxf, i.e. what size frames are accepted. 1683 /* Change maxf, i.e. what size frames are accepted.
@@ -1482,6 +1692,7 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1482 /* MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */ 1692 /* MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
1483 mac->bufsz = new_mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128; 1693 mac->bufsz = new_mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
1484 1694
1695out:
1485 if (running) { 1696 if (running) {
1486 write_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if), 1697 write_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
1487 rcmdsta | PAS_DMA_RXINT_RCMDSTA_EN); 1698 rcmdsta | PAS_DMA_RXINT_RCMDSTA_EN);
@@ -1494,7 +1705,7 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1494 pasemi_mac_intf_enable(mac); 1705 pasemi_mac_intf_enable(mac);
1495 } 1706 }
1496 1707
1497 return 0; 1708 return ret;
1498} 1709}
1499 1710
1500static int __devinit 1711static int __devinit
@@ -1528,7 +1739,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1528 netif_napi_add(dev, &mac->napi, pasemi_mac_poll, 64); 1739 netif_napi_add(dev, &mac->napi, pasemi_mac_poll, 64);
1529 1740
1530 dev->features = NETIF_F_IP_CSUM | NETIF_F_LLTX | NETIF_F_SG | 1741 dev->features = NETIF_F_IP_CSUM | NETIF_F_LLTX | NETIF_F_SG |
1531 NETIF_F_HIGHDMA; 1742 NETIF_F_HIGHDMA | NETIF_F_GSO;
1532 1743
1533 mac->lro_mgr.max_aggr = LRO_MAX_AGGR; 1744 mac->lro_mgr.max_aggr = LRO_MAX_AGGR;
1534 mac->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS; 1745 mac->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS;
@@ -1590,6 +1801,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1590 mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128; 1801 mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
1591 1802
1592 dev->change_mtu = pasemi_mac_change_mtu; 1803 dev->change_mtu = pasemi_mac_change_mtu;
1804 dev->ethtool_ops = &pasemi_mac_ethtool_ops;
1593 1805
1594 if (err) 1806 if (err)
1595 goto out; 1807 goto out;
diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h
index 99e7b9329a6f..1a115ec60b53 100644
--- a/drivers/net/pasemi_mac.h
+++ b/drivers/net/pasemi_mac.h
@@ -26,7 +26,14 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/phy.h> 27#include <linux/phy.h>
28 28
29/* Must be a power of two */
30#define RX_RING_SIZE 2048
31#define TX_RING_SIZE 4096
32#define CS_RING_SIZE (TX_RING_SIZE*2)
33
34
29#define MAX_LRO_DESCRIPTORS 8 35#define MAX_LRO_DESCRIPTORS 8
36#define MAX_CS 2
30 37
31struct pasemi_mac_txring { 38struct pasemi_mac_txring {
32 struct pasemi_dmachan chan; /* Must be first */ 39 struct pasemi_dmachan chan; /* Must be first */
@@ -51,6 +58,15 @@ struct pasemi_mac_rxring {
51 struct pasemi_mac *mac; /* Needed in intr handler */ 58 struct pasemi_mac *mac; /* Needed in intr handler */
52}; 59};
53 60
61struct pasemi_mac_csring {
62 struct pasemi_dmachan chan;
63 unsigned int size;
64 unsigned int next_to_fill;
65 int events[2];
66 int last_event;
67 int fun;
68};
69
54struct pasemi_mac { 70struct pasemi_mac {
55 struct net_device *netdev; 71 struct net_device *netdev;
56 struct pci_dev *pdev; 72 struct pci_dev *pdev;
@@ -60,10 +76,12 @@ struct pasemi_mac {
60 struct napi_struct napi; 76 struct napi_struct napi;
61 77
62 int bufsz; /* RX ring buffer size */ 78 int bufsz; /* RX ring buffer size */
79 int last_cs;
80 int num_cs;
81 u32 dma_if;
63 u8 type; 82 u8 type;
64#define MAC_TYPE_GMAC 1 83#define MAC_TYPE_GMAC 1
65#define MAC_TYPE_XAUI 2 84#define MAC_TYPE_XAUI 2
66 u32 dma_if;
67 85
68 u8 mac_addr[6]; 86 u8 mac_addr[6];
69 87
@@ -74,6 +92,7 @@ struct pasemi_mac {
74 92
75 struct pasemi_mac_txring *tx; 93 struct pasemi_mac_txring *tx;
76 struct pasemi_mac_rxring *rx; 94 struct pasemi_mac_rxring *rx;
95 struct pasemi_mac_csring *cs[MAX_CS];
77 char tx_irq_name[10]; /* "eth%d tx" */ 96 char tx_irq_name[10]; /* "eth%d tx" */
78 char rx_irq_name[10]; /* "eth%d rx" */ 97 char rx_irq_name[10]; /* "eth%d rx" */
79 int link; 98 int link;
@@ -90,6 +109,16 @@ struct pasemi_mac_buffer {
90 dma_addr_t dma; 109 dma_addr_t dma;
91}; 110};
92 111
112#define TX_DESC(tx, num) ((tx)->chan.ring_virt[(num) & (TX_RING_SIZE-1)])
113#define TX_DESC_INFO(tx, num) ((tx)->ring_info[(num) & (TX_RING_SIZE-1)])
114#define RX_DESC(rx, num) ((rx)->chan.ring_virt[(num) & (RX_RING_SIZE-1)])
115#define RX_DESC_INFO(rx, num) ((rx)->ring_info[(num) & (RX_RING_SIZE-1)])
116#define RX_BUFF(rx, num) ((rx)->buffers[(num) & (RX_RING_SIZE-1)])
117#define CS_DESC(cs, num) ((cs)->chan.ring_virt[(num) & (CS_RING_SIZE-1)])
118
119#define RING_USED(ring) (((ring)->next_to_fill - (ring)->next_to_clean) \
120 & ((ring)->size - 1))
121#define RING_AVAIL(ring) ((ring->size) - RING_USED(ring))
93 122
94/* PCI register offsets and formats */ 123/* PCI register offsets and formats */
95 124
@@ -101,6 +130,7 @@ enum {
101 PAS_MAC_CFG_ADR0 = 0x8c, 130 PAS_MAC_CFG_ADR0 = 0x8c,
102 PAS_MAC_CFG_ADR1 = 0x90, 131 PAS_MAC_CFG_ADR1 = 0x90,
103 PAS_MAC_CFG_TXP = 0x98, 132 PAS_MAC_CFG_TXP = 0x98,
133 PAS_MAC_CFG_RMON = 0x100,
104 PAS_MAC_IPC_CHNL = 0x208, 134 PAS_MAC_IPC_CHNL = 0x208,
105}; 135};
106 136
@@ -172,6 +202,8 @@ enum {
172#define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \ 202#define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \
173 PAS_MAC_CFG_TXP_TIFG_M) 203 PAS_MAC_CFG_TXP_TIFG_M)
174 204
205#define PAS_MAC_RMON(r) (0x100+(r)*4)
206
175#define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000 207#define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000
176#define PAS_MAC_IPC_CHNL_DCHNO_S 16 208#define PAS_MAC_IPC_CHNL_DCHNO_S 16
177#define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \ 209#define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \
@@ -181,4 +213,5 @@ enum {
181#define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \ 213#define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \
182 PAS_MAC_IPC_CHNL_BCH_M) 214 PAS_MAC_IPC_CHNL_BCH_M)
183 215
216
184#endif /* PASEMI_MAC_H */ 217#endif /* PASEMI_MAC_H */
diff --git a/drivers/net/pasemi_mac_ethtool.c b/drivers/net/pasemi_mac_ethtool.c
new file mode 100644
index 000000000000..5e8df3afea64
--- /dev/null
+++ b/drivers/net/pasemi_mac_ethtool.c
@@ -0,0 +1,159 @@
1/*
2 * Copyright (C) 2006-2008 PA Semi, Inc
3 *
4 * Ethtool hooks for the PA Semi PWRficient onchip 1G/10G Ethernet MACs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20
21#include <linux/netdevice.h>
22#include <linux/ethtool.h>
23#include <linux/pci.h>
24#include <linux/inet_lro.h>
25
26#include <asm/pasemi_dma.h>
27#include "pasemi_mac.h"
28
29static struct {
30 const char str[ETH_GSTRING_LEN];
31} ethtool_stats_keys[] = {
32 { "rx-drops" },
33 { "rx-bytes" },
34 { "rx-packets" },
35 { "rx-broadcast-packets" },
36 { "rx-multicast-packets" },
37 { "rx-crc-errors" },
38 { "rx-undersize-errors" },
39 { "rx-oversize-errors" },
40 { "rx-short-fragment-errors" },
41 { "rx-jabber-errors" },
42 { "rx-64-byte-packets" },
43 { "rx-65-127-byte-packets" },
44 { "rx-128-255-byte-packets" },
45 { "rx-256-511-byte-packets" },
46 { "rx-512-1023-byte-packets" },
47 { "rx-1024-1518-byte-packets" },
48 { "rx-pause-frames" },
49 { "tx-bytes" },
50 { "tx-packets" },
51 { "tx-broadcast-packets" },
52 { "tx-multicast-packets" },
53 { "tx-collisions" },
54 { "tx-late-collisions" },
55 { "tx-excessive-collisions" },
56 { "tx-crc-errors" },
57 { "tx-undersize-errors" },
58 { "tx-oversize-errors" },
59 { "tx-64-byte-packets" },
60 { "tx-65-127-byte-packets" },
61 { "tx-128-255-byte-packets" },
62 { "tx-256-511-byte-packets" },
63 { "tx-512-1023-byte-packets" },
64 { "tx-1024-1518-byte-packets" },
65};
66
67static int
68pasemi_mac_ethtool_get_settings(struct net_device *netdev,
69 struct ethtool_cmd *cmd)
70{
71 struct pasemi_mac *mac = netdev_priv(netdev);
72 struct phy_device *phydev = mac->phydev;
73
74 return phy_ethtool_gset(phydev, cmd);
75}
76
77static void
78pasemi_mac_ethtool_get_drvinfo(struct net_device *netdev,
79 struct ethtool_drvinfo *drvinfo)
80{
81 struct pasemi_mac *mac;
82 mac = netdev_priv(netdev);
83
84 /* clear and fill out info */
85 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
86 strncpy(drvinfo->driver, "pasemi_mac", 12);
87 strcpy(drvinfo->version, "N/A");
88 strcpy(drvinfo->fw_version, "N/A");
89 strncpy(drvinfo->bus_info, pci_name(mac->pdev), 32);
90}
91
92static u32
93pasemi_mac_ethtool_get_msglevel(struct net_device *netdev)
94{
95 struct pasemi_mac *mac = netdev_priv(netdev);
96 return mac->msg_enable;
97}
98
99static void
100pasemi_mac_ethtool_set_msglevel(struct net_device *netdev,
101 u32 level)
102{
103 struct pasemi_mac *mac = netdev_priv(netdev);
104 mac->msg_enable = level;
105}
106
107
108static void
109pasemi_mac_ethtool_get_ringparam(struct net_device *netdev,
110 struct ethtool_ringparam *ering)
111{
112 struct pasemi_mac *mac = netdev->priv;
113
114 ering->tx_max_pending = TX_RING_SIZE/2;
115 ering->tx_pending = RING_USED(mac->tx)/2;
116 ering->rx_max_pending = RX_RING_SIZE/4;
117 ering->rx_pending = RING_USED(mac->rx)/4;
118}
119
120static int pasemi_mac_get_sset_count(struct net_device *netdev, int sset)
121{
122 switch (sset) {
123 case ETH_SS_STATS:
124 return ARRAY_SIZE(ethtool_stats_keys);
125 default:
126 return -EOPNOTSUPP;
127 }
128}
129
130static void pasemi_mac_get_ethtool_stats(struct net_device *netdev,
131 struct ethtool_stats *stats, u64 *data)
132{
133 struct pasemi_mac *mac = netdev->priv;
134 int i;
135
136 data[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if))
137 >> PAS_DMA_RXINT_RCMDSTA_DROPS_S;
138 for (i = 0; i < 32; i++)
139 data[1+i] = pasemi_read_mac_reg(mac->dma_if, PAS_MAC_RMON(i));
140}
141
142static void pasemi_mac_get_strings(struct net_device *netdev, u32 stringset,
143 u8 *data)
144{
145 memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
146}
147
148const struct ethtool_ops pasemi_mac_ethtool_ops = {
149 .get_settings = pasemi_mac_ethtool_get_settings,
150 .get_drvinfo = pasemi_mac_ethtool_get_drvinfo,
151 .get_msglevel = pasemi_mac_ethtool_get_msglevel,
152 .set_msglevel = pasemi_mac_ethtool_set_msglevel,
153 .get_link = ethtool_op_get_link,
154 .get_ringparam = pasemi_mac_ethtool_get_ringparam,
155 .get_strings = pasemi_mac_get_strings,
156 .get_sset_count = pasemi_mac_get_sset_count,
157 .get_ethtool_stats = pasemi_mac_get_ethtool_stats,
158};
159
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 7eb6e7e848f4..e365efb3c627 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -1266,6 +1266,85 @@ int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
1266 return 0; 1266 return 0;
1267} 1267}
1268 1268
1269static void gelic_net_get_wol(struct net_device *netdev,
1270 struct ethtool_wolinfo *wol)
1271{
1272 if (0 <= ps3_compare_firmware_version(2, 2, 0))
1273 wol->supported = WAKE_MAGIC;
1274 else
1275 wol->supported = 0;
1276
1277 wol->wolopts = ps3_sys_manager_get_wol() ? wol->supported : 0;
1278 memset(&wol->sopass, 0, sizeof(wol->sopass));
1279}
1280static int gelic_net_set_wol(struct net_device *netdev,
1281 struct ethtool_wolinfo *wol)
1282{
1283 int status;
1284 struct gelic_card *card;
1285 u64 v1, v2;
1286
1287 if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
1288 !capable(CAP_NET_ADMIN))
1289 return -EPERM;
1290
1291 if (wol->wolopts & ~WAKE_MAGIC)
1292 return -EINVAL;
1293
1294 card = netdev_card(netdev);
1295 if (wol->wolopts & WAKE_MAGIC) {
1296 status = lv1_net_control(bus_id(card), dev_id(card),
1297 GELIC_LV1_SET_WOL,
1298 GELIC_LV1_WOL_MAGIC_PACKET,
1299 0, GELIC_LV1_WOL_MP_ENABLE,
1300 &v1, &v2);
1301 if (status) {
1302 pr_info("%s: enabling WOL failed %d\n", __func__,
1303 status);
1304 status = -EIO;
1305 goto done;
1306 }
1307 status = lv1_net_control(bus_id(card), dev_id(card),
1308 GELIC_LV1_SET_WOL,
1309 GELIC_LV1_WOL_ADD_MATCH_ADDR,
1310 0, GELIC_LV1_WOL_MATCH_ALL,
1311 &v1, &v2);
1312 if (!status)
1313 ps3_sys_manager_set_wol(1);
1314 else {
1315 pr_info("%s: enabling WOL filter failed %d\n",
1316 __func__, status);
1317 status = -EIO;
1318 }
1319 } else {
1320 status = lv1_net_control(bus_id(card), dev_id(card),
1321 GELIC_LV1_SET_WOL,
1322 GELIC_LV1_WOL_MAGIC_PACKET,
1323 0, GELIC_LV1_WOL_MP_DISABLE,
1324 &v1, &v2);
1325 if (status) {
1326 pr_info("%s: disabling WOL failed %d\n", __func__,
1327 status);
1328 status = -EIO;
1329 goto done;
1330 }
1331 status = lv1_net_control(bus_id(card), dev_id(card),
1332 GELIC_LV1_SET_WOL,
1333 GELIC_LV1_WOL_DELETE_MATCH_ADDR,
1334 0, GELIC_LV1_WOL_MATCH_ALL,
1335 &v1, &v2);
1336 if (!status)
1337 ps3_sys_manager_set_wol(0);
1338 else {
1339 pr_info("%s: removing WOL filter failed %d\n",
1340 __func__, status);
1341 status = -EIO;
1342 }
1343 }
1344done:
1345 return status;
1346}
1347
1269static struct ethtool_ops gelic_ether_ethtool_ops = { 1348static struct ethtool_ops gelic_ether_ethtool_ops = {
1270 .get_drvinfo = gelic_net_get_drvinfo, 1349 .get_drvinfo = gelic_net_get_drvinfo,
1271 .get_settings = gelic_ether_get_settings, 1350 .get_settings = gelic_ether_get_settings,
@@ -1274,6 +1353,8 @@ static struct ethtool_ops gelic_ether_ethtool_ops = {
1274 .set_tx_csum = ethtool_op_set_tx_csum, 1353 .set_tx_csum = ethtool_op_set_tx_csum,
1275 .get_rx_csum = gelic_net_get_rx_csum, 1354 .get_rx_csum = gelic_net_get_rx_csum,
1276 .set_rx_csum = gelic_net_set_rx_csum, 1355 .set_rx_csum = gelic_net_set_rx_csum,
1356 .get_wol = gelic_net_get_wol,
1357 .set_wol = gelic_net_set_wol,
1277}; 1358};
1278 1359
1279/** 1360/**
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 1d39d06797e4..520f143c2c09 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -182,12 +182,32 @@ enum gelic_lv1_net_control_code {
182 GELIC_LV1_GET_ETH_PORT_STATUS = 2, 182 GELIC_LV1_GET_ETH_PORT_STATUS = 2,
183 GELIC_LV1_SET_NEGOTIATION_MODE = 3, 183 GELIC_LV1_SET_NEGOTIATION_MODE = 3,
184 GELIC_LV1_GET_VLAN_ID = 4, 184 GELIC_LV1_GET_VLAN_ID = 4,
185 GELIC_LV1_SET_WOL = 5,
185 GELIC_LV1_GET_CHANNEL = 6, 186 GELIC_LV1_GET_CHANNEL = 6,
186 GELIC_LV1_POST_WLAN_CMD = 9, 187 GELIC_LV1_POST_WLAN_CMD = 9,
187 GELIC_LV1_GET_WLAN_CMD_RESULT = 10, 188 GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
188 GELIC_LV1_GET_WLAN_EVENT = 11 189 GELIC_LV1_GET_WLAN_EVENT = 11
189}; 190};
190 191
192/* for GELIC_LV1_SET_WOL */
193enum gelic_lv1_wol_command {
194 GELIC_LV1_WOL_MAGIC_PACKET = 1,
195 GELIC_LV1_WOL_ADD_MATCH_ADDR = 6,
196 GELIC_LV1_WOL_DELETE_MATCH_ADDR = 7,
197};
198
199/* for GELIC_LV1_WOL_MAGIC_PACKET */
200enum gelic_lv1_wol_mp_arg {
201 GELIC_LV1_WOL_MP_DISABLE = 0,
202 GELIC_LV1_WOL_MP_ENABLE = 1,
203};
204
205/* for GELIC_LV1_WOL_{ADD,DELETE}_MATCH_ADDR */
206enum gelic_lv1_wol_match_arg {
207 GELIC_LV1_WOL_MATCH_INDIVIDUAL = 0,
208 GELIC_LV1_WOL_MATCH_ALL = 1,
209};
210
191/* status returened from GET_ETH_PORT_STATUS */ 211/* status returened from GET_ETH_PORT_STATUS */
192enum gelic_lv1_ether_port_status { 212enum gelic_lv1_ether_port_status {
193 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L, 213 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 80c9deca5f35..9bd7c4a31253 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -117,6 +117,32 @@ int of_device_is_compatible(const struct device_node *device,
117EXPORT_SYMBOL(of_device_is_compatible); 117EXPORT_SYMBOL(of_device_is_compatible);
118 118
119/** 119/**
120 * of_device_is_available - check if a device is available for use
121 *
122 * @device: Node to check for availability
123 *
124 * Returns 1 if the status property is absent or set to "okay" or "ok",
125 * 0 otherwise
126 */
127int of_device_is_available(const struct device_node *device)
128{
129 const char *status;
130 int statlen;
131
132 status = of_get_property(device, "status", &statlen);
133 if (status == NULL)
134 return 1;
135
136 if (statlen > 0) {
137 if (!strcmp(status, "okay") || !strcmp(status, "ok"))
138 return 1;
139 }
140
141 return 0;
142}
143EXPORT_SYMBOL(of_device_is_available);
144
145/**
120 * of_get_parent - Get a node's parent if any 146 * of_get_parent - Get a node's parent if any
121 * @node: Node to get parent 147 * @node: Node to get parent
122 * 148 *
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c
index d4f6f960dd18..7605453b74fd 100644
--- a/drivers/ps3/ps3-sys-manager.c
+++ b/drivers/ps3/ps3-sys-manager.c
@@ -24,6 +24,7 @@
24#include <linux/reboot.h> 24#include <linux/reboot.h>
25 25
26#include <asm/firmware.h> 26#include <asm/firmware.h>
27#include <asm/lv1call.h>
27#include <asm/ps3.h> 28#include <asm/ps3.h>
28 29
29#include "vuart.h" 30#include "vuart.h"
@@ -187,6 +188,7 @@ enum ps3_sys_manager_next_op {
187 * controller, and bluetooth controller. 188 * controller, and bluetooth controller.
188 * @PS3_SM_WAKE_RTC: 189 * @PS3_SM_WAKE_RTC:
189 * @PS3_SM_WAKE_RTC_ERROR: 190 * @PS3_SM_WAKE_RTC_ERROR:
191 * @PS3_SM_WAKE_W_O_L: Ether or wireless LAN.
190 * @PS3_SM_WAKE_P_O_R: Power on reset. 192 * @PS3_SM_WAKE_P_O_R: Power on reset.
191 * 193 *
192 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. 194 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN.
@@ -200,10 +202,19 @@ enum ps3_sys_manager_wake_source {
200 PS3_SM_WAKE_DEFAULT = 0, 202 PS3_SM_WAKE_DEFAULT = 0,
201 PS3_SM_WAKE_RTC = 0x00000040, 203 PS3_SM_WAKE_RTC = 0x00000040,
202 PS3_SM_WAKE_RTC_ERROR = 0x00000080, 204 PS3_SM_WAKE_RTC_ERROR = 0x00000080,
205 PS3_SM_WAKE_W_O_L = 0x00000400,
203 PS3_SM_WAKE_P_O_R = 0x80000000, 206 PS3_SM_WAKE_P_O_R = 0x80000000,
204}; 207};
205 208
206/** 209/**
210 * user_wake_sources - User specified wakeup sources.
211 *
212 * Logical OR of enum ps3_sys_manager_wake_source types.
213 */
214
215static u32 user_wake_sources = PS3_SM_WAKE_DEFAULT;
216
217/**
207 * enum ps3_sys_manager_cmd - Command from system manager to guest. 218 * enum ps3_sys_manager_cmd - Command from system manager to guest.
208 * 219 *
209 * The guest completes the actions needed, then acks or naks the command via 220 * The guest completes the actions needed, then acks or naks the command via
@@ -581,6 +592,23 @@ fail_id:
581 return -EIO; 592 return -EIO;
582} 593}
583 594
595static void ps3_sys_manager_fin(struct ps3_system_bus_device *dev)
596{
597 ps3_sys_manager_send_request_shutdown(dev);
598
599 pr_emerg("System Halted, OK to turn off power\n");
600
601 while (ps3_sys_manager_handle_msg(dev)) {
602 /* pause until next DEC interrupt */
603 lv1_pause(0);
604 }
605
606 while (1) {
607 /* pause, ignoring DEC interrupt */
608 lv1_pause(1);
609 }
610}
611
584/** 612/**
585 * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. 613 * ps3_sys_manager_final_power_off - The final platform machine_power_off routine.
586 * 614 *
@@ -601,13 +629,9 @@ static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev)
601 ps3_vuart_cancel_async(dev); 629 ps3_vuart_cancel_async(dev);
602 630
603 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, 631 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN,
604 PS3_SM_WAKE_DEFAULT); 632 user_wake_sources);
605 ps3_sys_manager_send_request_shutdown(dev);
606
607 pr_emerg("System Halted, OK to turn off power\n");
608 633
609 while (1) 634 ps3_sys_manager_fin(dev);
610 ps3_sys_manager_handle_msg(dev);
611} 635}
612 636
613/** 637/**
@@ -638,14 +662,42 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev)
638 662
639 ps3_sys_manager_send_attr(dev, 0); 663 ps3_sys_manager_send_attr(dev, 0);
640 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT, 664 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT,
641 PS3_SM_WAKE_DEFAULT); 665 user_wake_sources);
642 ps3_sys_manager_send_request_shutdown(dev);
643 666
644 pr_emerg("System Halted, OK to turn off power\n"); 667 ps3_sys_manager_fin(dev);
668}
669
670/**
671 * ps3_sys_manager_get_wol - Get wake-on-lan setting.
672 */
673
674int ps3_sys_manager_get_wol(void)
675{
676 pr_debug("%s:%d\n", __func__, __LINE__);
677
678 return (user_wake_sources & PS3_SM_WAKE_W_O_L) != 0;
679}
680EXPORT_SYMBOL_GPL(ps3_sys_manager_get_wol);
681
682/**
683 * ps3_sys_manager_set_wol - Set wake-on-lan setting.
684 */
685
686void ps3_sys_manager_set_wol(int state)
687{
688 static DEFINE_MUTEX(mutex);
689
690 mutex_lock(&mutex);
691
692 pr_debug("%s:%d: %d\n", __func__, __LINE__, state);
645 693
646 while (1) 694 if (state)
647 ps3_sys_manager_handle_msg(dev); 695 user_wake_sources |= PS3_SM_WAKE_W_O_L;
696 else
697 user_wake_sources &= ~PS3_SM_WAKE_W_O_L;
698 mutex_unlock(&mutex);
648} 699}
700EXPORT_SYMBOL_GPL(ps3_sys_manager_set_wol);
649 701
650/** 702/**
651 * ps3_sys_manager_work - Asynchronous read handler. 703 * ps3_sys_manager_work - Asynchronous read handler.
diff --git a/drivers/ps3/sys-manager-core.c b/drivers/ps3/sys-manager-core.c
index 31648f7d9ae1..474225852b63 100644
--- a/drivers/ps3/sys-manager-core.c
+++ b/drivers/ps3/sys-manager-core.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <asm/lv1call.h>
22#include <asm/ps3.h> 23#include <asm/ps3.h>
23 24
24/** 25/**
@@ -50,10 +51,7 @@ void ps3_sys_manager_power_off(void)
50 if (ps3_sys_manager_ops.power_off) 51 if (ps3_sys_manager_ops.power_off)
51 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev); 52 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
52 53
53 printk(KERN_EMERG "System Halted, OK to turn off power\n"); 54 ps3_sys_manager_halt();
54 local_irq_disable();
55 while (1)
56 (void)0;
57} 55}
58 56
59void ps3_sys_manager_restart(void) 57void ps3_sys_manager_restart(void)
@@ -61,8 +59,14 @@ void ps3_sys_manager_restart(void)
61 if (ps3_sys_manager_ops.restart) 59 if (ps3_sys_manager_ops.restart)
62 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev); 60 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
63 61
64 printk(KERN_EMERG "System Halted, OK to turn off power\n"); 62 ps3_sys_manager_halt();
63}
64
65void ps3_sys_manager_halt(void)
66{
67 pr_emerg("System Halted, OK to turn off power\n");
65 local_irq_disable(); 68 local_irq_disable();
66 while (1) 69 while (1)
67 (void)0; 70 lv1_pause(1);
68} 71}
72
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index c0e50a461055..8aacfb78deab 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,
56 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 56 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
57 | UPF_FIXED_PORT; 57 | UPF_FIXED_PORT;
58 port->dev = &ofdev->dev; 58 port->dev = &ofdev->dev;
59 port->custom_divisor = *clk / (16 * (*spd)); 59 /* If current-speed was set, then try not to change it. */
60 if (spd)
61 port->custom_divisor = *clk / (16 * (*spd));
60 62
61 return 0; 63 return 0;
62} 64}