1 diff -Naurp a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c 2 --- a/arch/powerpc/kvm/book3s_emulate.c 2013-07-01 00:13:29.000000000 +0200 3 +++ b/arch/powerpc/kvm/book3s_emulate.c 2013-09-05 02:02:56.000000000 +0200 4 @@ -458,6 +458,7 @@ int kvmppc_core_emulate_mtspr(struct kvm 5 case SPRN_PMC4_GEKKO: 6 case SPRN_WPAR_GEKKO: 7 case SPRN_MSSSR0: 8 + case SPRN_DABR: 9 break; 10 unprivileged: 11 default: 12 @@ -555,6 +556,7 @@ int kvmppc_core_emulate_mfspr(struct kvm 13 case SPRN_PMC4_GEKKO: 14 case SPRN_WPAR_GEKKO: 15 case SPRN_MSSSR0: 16 + case SPRN_DABR: 17 *spr_val = 0; 18 break; 19 default: 20 diff -Naurp a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c 21 --- a/drivers/i2c/busses/i2c-powermac.c 2013-07-01 00:13:29.000000000 +0200 22 +++ b/drivers/i2c/busses/i2c-powermac.c 2013-08-29 06:18:10.000000000 +0200 23 @@ -220,138 +220,28 @@ static int i2c_powermac_remove(struct pl 24 return 0; 25 } 26 27 -static u32 i2c_powermac_get_addr(struct i2c_adapter *adap, 28 - struct pmac_i2c_bus *bus, 29 - struct device_node *node) 30 -{ 31 - const __be32 *prop; 32 - int len; 33 - 34 - /* First check for valid "reg" */ 35 - prop = of_get_property(node, "reg", &len); 36 - if (prop && (len >= sizeof(int))) 37 - return (be32_to_cpup(prop) & 0xff) >> 1; 38 - 39 - /* Then check old-style "i2c-address" */ 40 - prop = of_get_property(node, "i2c-address", &len); 41 - if (prop && (len >= sizeof(int))) 42 - return (be32_to_cpup(prop) & 0xff) >> 1; 43 - 44 - /* Now handle some devices with missing "reg" properties */ 45 - if (!strcmp(node->name, "cereal")) 46 - return 0x60; 47 - else if (!strcmp(node->name, "deq")) 48 - return 0x34; 49 - 50 - dev_warn(&adap->dev, "No i2c address for %s\n", node->full_name); 51 - 52 - return 0xffffffff; 53 -} 54 - 55 -static void i2c_powermac_create_one(struct i2c_adapter *adap, 56 - const char *type, 57 - u32 addr) 58 -{ 59 - struct i2c_board_info info = {}; 60 - struct i2c_client *newdev; 61 - 62 - strncpy(info.type, type, sizeof(info.type)); 63 - info.addr = addr; 64 - newdev = i2c_new_device(adap, &info); 65 - if (!newdev) 66 - dev_err(&adap->dev, 67 - "i2c-powermac: Failure to register missing %s\n", 68 - type); 69 -} 70 - 71 -static void i2c_powermac_add_missing(struct i2c_adapter *adap, 72 - struct pmac_i2c_bus *bus, 73 - bool found_onyx) 74 -{ 75 - struct device_node *busnode = pmac_i2c_get_bus_node(bus); 76 - int rc; 77 - 78 - /* Check for the onyx audio codec */ 79 -#define ONYX_REG_CONTROL 67 80 - if (of_device_is_compatible(busnode, "k2-i2c") && !found_onyx) { 81 - union i2c_smbus_data data; 82 - 83 - rc = i2c_smbus_xfer(adap, 0x46, 0, I2C_SMBUS_READ, 84 - ONYX_REG_CONTROL, I2C_SMBUS_BYTE_DATA, 85 - &data); 86 - if (rc >= 0) 87 - i2c_powermac_create_one(adap, "MAC,pcm3052", 0x46); 88 - 89 - rc = i2c_smbus_xfer(adap, 0x47, 0, I2C_SMBUS_READ, 90 - ONYX_REG_CONTROL, I2C_SMBUS_BYTE_DATA, 91 - &data); 92 - if (rc >= 0) 93 - i2c_powermac_create_one(adap, "MAC,pcm3052", 0x47); 94 - } 95 -} 96 - 97 -static bool i2c_powermac_get_type(struct i2c_adapter *adap, 98 - struct device_node *node, 99 - u32 addr, char *type, int type_size) 100 -{ 101 - char tmp[16]; 102 - 103 - /* Note: we to _NOT_ want the standard 104 - * i2c drivers to match with any of our powermac stuff 105 - * unless they have been specifically modified to handle 106 - * it on a case by case basis. For example, for thermal 107 - * control, things like lm75 etc... shall match with their 108 - * corresponding windfarm drivers, _NOT_ the generic ones, 109 - * so we force a prefix of AAPL, onto the modalias to 110 - * make that happen 111 - */ 112 - 113 - /* First try proper modalias */ 114 - if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) { 115 - snprintf(type, type_size, "MAC,%s", tmp); 116 - return true; 117 - } 118 - 119 - /* Now look for known workarounds */ 120 - if (!strcmp(node->name, "deq")) { 121 - /* Apple uses address 0x34 for TAS3001 and 0x35 for TAS3004 */ 122 - if (addr == 0x34) { 123 - snprintf(type, type_size, "MAC,tas3001"); 124 - return true; 125 - } else if (addr == 0x35) { 126 - snprintf(type, type_size, "MAC,tas3004"); 127 - return true; 128 - } 129 - } 130 - 131 - dev_err(&adap->dev, "i2c-powermac: modalias failure" 132 - " on %s\n", node->full_name); 133 - return false; 134 -} 135 - 136 static void i2c_powermac_register_devices(struct i2c_adapter *adap, 137 struct pmac_i2c_bus *bus) 138 { 139 struct i2c_client *newdev; 140 struct device_node *node; 141 - bool found_onyx = 0; 142 - 143 - /* 144 - * In some cases we end up with the via-pmu node itself, in this 145 - * case we skip this function completely as the device-tree will 146 - * not contain anything useful. 147 - */ 148 - if (!strcmp(adap->dev.of_node->name, "via-pmu")) 149 - return; 150 151 for_each_child_of_node(adap->dev.of_node, node) { 152 struct i2c_board_info info = {}; 153 + struct dev_archdata dev_ad = {}; 154 + const __be32 *reg; 155 + char tmp[16]; 156 u32 addr; 157 + int len; 158 159 /* Get address & channel */ 160 - addr = i2c_powermac_get_addr(adap, bus, node); 161 - if (addr == 0xffffffff) 162 + reg = of_get_property(node, "reg", &len); 163 + if (!reg || (len < sizeof(int))) { 164 + dev_err(&adap->dev, "i2c-powermac: invalid reg on %s\n", 165 + node->full_name); 166 continue; 167 + } 168 + addr = be32_to_cpup(reg); 169 170 /* Multibus setup, check channel */ 171 if (!pmac_i2c_match_adapter(node, adap)) 172 @@ -360,23 +250,18 @@ static void i2c_powermac_register_device 173 dev_dbg(&adap->dev, "i2c-powermac: register %s\n", 174 node->full_name); 175 176 - /* 177 - * Keep track of some device existence to handle 178 - * workarounds later. 179 - */ 180 - if (of_device_is_compatible(node, "pcm3052")) 181 - found_onyx = true; 182 - 183 - /* Make up a modalias */ 184 - if (!i2c_powermac_get_type(adap, node, addr, 185 - info.type, sizeof(info.type))) { 186 + if (of_modalias_node(node, tmp, sizeof(tmp)) < 0) { 187 + dev_err(&adap->dev, "i2c-powermac: modalias failure" 188 + " on %s\n", node->full_name); 189 continue; 190 } 191 + snprintf(info.type, sizeof(info.type), "MAC,%s", tmp); 192 193 /* Fill out the rest of the info structure */ 194 - info.addr = addr; 195 + info.addr = (addr & 0xff) >> 1; 196 info.irq = irq_of_parse_and_map(node, 0); 197 info.of_node = of_node_get(node); 198 + info.archdata = &dev_ad; 199 200 newdev = i2c_new_device(adap, &info); 201 if (!newdev) { 202 @@ -391,9 +276,6 @@ static void i2c_powermac_register_device 203 continue; 204 } 205 } 206 - 207 - /* Additional workarounds */ 208 - i2c_powermac_add_missing(adap, bus, found_onyx); 209 } 210 211 static int i2c_powermac_probe(struct platform_device *dev) 212 diff -Naurp a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig 213 --- a/drivers/macintosh/Kconfig 2013-07-01 00:13:29.000000000 +0200 214 +++ b/drivers/macintosh/Kconfig 2013-08-29 16:24:28.000000000 +0200 215 @@ -171,6 +171,13 @@ config INPUT_ADBHID 216 217 If unsure, say Y. 218 219 +config ADB_TRACKPAD_ABSOLUTE 220 + bool "Enable absolute mode for adb trackpads" 221 + depends on INPUT_ADBHID 222 + help 223 + Enable absolute mode in adb-base trackpads. This feature adds 224 + compatibility with synaptics Xorg / Xfree drivers. 225 + 226 config MAC_EMUMOUSEBTN 227 tristate "Support for mouse button 2+3 emulation" 228 depends on SYSCTL && INPUT 229 diff -Naurp a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c 230 --- a/drivers/macintosh/adbhid.c 2013-07-01 00:13:29.000000000 +0200 231 +++ b/drivers/macintosh/adbhid.c 2013-08-29 16:26:47.000000000 +0200 232 @@ -261,6 +261,15 @@ static struct adb_ids buttons_ids; 233 #define ADBMOUSE_MS_A3 8 /* Mouse systems A3 trackball (handler 3) */ 234 #define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */ 235 236 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 237 +#define ABS_XMIN 310 238 +#define ABS_XMAX 1700 239 +#define ABS_YMIN 200 240 +#define ABS_YMAX 1000 241 +#define ABS_ZMIN 0 242 +#define ABS_ZMAX 55 243 +#endif 244 + 245 static void 246 adbhid_keyboard_input(unsigned char *data, int nb, int apoll) 247 { 248 @@ -405,6 +414,9 @@ static void 249 adbhid_mouse_input(unsigned char *data, int nb, int autopoll) 250 { 251 int id = (data[0] >> 4) & 0x0f; 252 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 253 + int btn = 0; int x_axis = 0; int y_axis = 0; int z_axis = 0; 254 +#endif 255 256 if (!adbhid[id]) { 257 printk(KERN_ERR "ADB HID on ID %d not yet registered\n", id); 258 @@ -436,6 +448,17 @@ adbhid_mouse_input(unsigned char *data, 259 high bits of y-axis motion. XY is additional 260 high bits of x-axis motion. 261 262 + For ADB Absolute motion protocol the data array will contain the 263 + following values: 264 + 265 + BITS COMMENTS 266 + data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd. 267 + data[1] = byyy yyyy Left button and y-axis motion. 268 + data[2] = bxxx xxxx Second button and x-axis motion. 269 + data[3] = 1yyy 1xxx Half bits of y-axis and x-axis motion. 270 + data[4] = 1yyy 1xxx Higher bits of y-axis and x-axis motion. 271 + data[5] = 1zzz 1zzz Higher and lower bits of z-pressure. 272 + 273 MacAlly 2-button mouse protocol. 274 275 For MacAlly 2-button mouse protocol the data array will contain the 276 @@ -458,8 +481,17 @@ adbhid_mouse_input(unsigned char *data, 277 switch (adbhid[id]->mouse_kind) 278 { 279 case ADBMOUSE_TRACKPAD: 280 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 281 + x_axis = (data[2] & 0x7f) | ((data[3] & 0x07) << 7) | 282 + ((data[4] & 0x07) << 10); 283 + y_axis = (data[1] & 0x7f) | ((data[3] & 0x70) << 3) | 284 + ((data[4] & 0x70) << 6); 285 + z_axis = (data[5] & 0x07) | ((data[5] & 0x70) >> 1); 286 + btn = (!(data[1] >> 7)) & 1; 287 +#else 288 data[1] = (data[1] & 0x7f) | ((data[1] & data[2]) & 0x80); 289 data[2] = data[2] | 0x80; 290 +#endif 291 break; 292 case ADBMOUSE_MICROSPEED: 293 data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7); 294 @@ -485,17 +517,39 @@ adbhid_mouse_input(unsigned char *data, 295 break; 296 } 297 298 - input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); 299 - input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); 300 - 301 - if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) 302 - input_report_key(adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); 303 - 304 - input_report_rel(adbhid[id]->input, REL_X, 305 - ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); 306 - input_report_rel(adbhid[id]->input, REL_Y, 307 - ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); 308 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 309 + if ( adbhid[id]->mouse_kind == ADBMOUSE_TRACKPAD ) { 310 + 311 + if(z_axis > 30) input_report_key(adbhid[id]->input, BTN_TOUCH, 1); 312 + if(z_axis < 25) input_report_key(adbhid[id]->input, BTN_TOUCH, 0); 313 + 314 + if(z_axis > 0){ 315 + input_report_abs(adbhid[id]->input, ABS_X, x_axis); 316 + input_report_abs(adbhid[id]->input, ABS_Y, y_axis); 317 + input_report_key(adbhid[id]->input, BTN_TOOL_FINGER, 1); 318 + input_report_key(adbhid[id]->input, ABS_TOOL_WIDTH, 5); 319 + } else { 320 + input_report_key(adbhid[id]->input, BTN_TOOL_FINGER, 0); 321 + input_report_key(adbhid[id]->input, ABS_TOOL_WIDTH, 0); 322 + } 323 324 + input_report_abs(adbhid[id]->input, ABS_PRESSURE, z_axis); 325 + input_report_key(adbhid[id]->input, BTN_LEFT, btn); 326 + } else { 327 +#endif 328 + input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); 329 + input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); 330 + 331 + if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) 332 + input_report_key(adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); 333 + 334 + input_report_rel(adbhid[id]->input, REL_X, 335 + ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); 336 + input_report_rel(adbhid[id]->input, REL_Y, 337 + ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); 338 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 339 + } 340 +#endif 341 input_sync(adbhid[id]->input); 342 } 343 344 @@ -849,6 +903,15 @@ adbhid_input_register(int id, int defaul 345 input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 346 BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); 347 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 348 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 349 + set_bit(EV_ABS, input_dev->evbit); 350 + input_set_abs_params(input_dev, ABS_X, ABS_XMIN, ABS_XMAX, 0, 0); 351 + input_set_abs_params(input_dev, ABS_Y, ABS_YMIN, ABS_YMAX, 0, 0); 352 + input_set_abs_params(input_dev, ABS_PRESSURE, ABS_ZMIN, ABS_ZMAX, 0, 0); 353 + set_bit(BTN_TOUCH, input_dev->keybit); 354 + set_bit(BTN_TOOL_FINGER, input_dev->keybit); 355 + set_bit(ABS_TOOL_WIDTH, input_dev->absbit); 356 +#endif 357 break; 358 359 case ADB_MISC: 360 @@ -1132,7 +1195,11 @@ init_trackpad(int id) 361 r1_buffer[3], 362 r1_buffer[4], 363 r1_buffer[5], 364 +#ifdef CONFIG_ADB_TRACKPAD_ABSOLUTE 365 + 0x00, /* Enable absolute mode */ 366 +#else 367 0x03, /*r1_buffer[6],*/ 368 +#endif 369 r1_buffer[7]); 370 371 /* Without this flush, the trackpad may be locked up */