0004-fixes.patch (21701B)
1 From 3c34e5f87a741ec2fc7809fc8c169a832275d32c Mon Sep 17 00:00:00 2001 2 From: John Crispin <blogic@openwrt.org> 3 Date: Thu, 23 Jul 2015 18:19:32 +0200 4 Subject: [PATCH 4/4] fixes 5 6 --- 7 src/mips/mediatek.c | 6 +++++- 8 1 file changed, 5 insertions(+), 1 deletion(-) 9 10 --- a/src/mips/mediatek.c 11 +++ b/src/mips/mediatek.c 12 @@ -37,12 +37,12 @@ 13 #define PLATFORM_MEDIATEK_LINKIT 1 14 #define PLATFORM_MEDIATEK_LINKIT_AIR 2 15 #define MMAP_PATH "/dev/mem" 16 -#define MT7628_GPIO_BASE 0x100 17 -#define MT7628_BLOCK_SIZE (4 * 1024) 18 -#define MT7628_GPIO_CTRL 0x00 19 -#define MT7628_GPIO_DATA 0x20 20 -#define MT7628_GPIO_SET 0x30 21 -#define MT7628_GPIO_CLEAR 0x40 22 +#define MT7628_GPIOMODE_BASE 0x10000000 23 +#define MT7628_BLOCK_SIZE 0x1000 24 +#define MT7628_GPIO_CTRL 0x600 25 +#define MT7628_GPIO_DATA 0x620 26 +#define MT7628_GPIO_SET 0x630 27 +#define MT7628_GPIO_CLEAR 0x640 28 29 #define MAX_SIZE 64 30 31 @@ -50,6 +50,9 @@ 32 static uint8_t* mmap_reg = NULL; 33 static int mmap_fd = 0; 34 static int mmap_size; 35 +static uint8_t* gpio_mmap_reg = NULL; 36 +static int gpio_mmap_fd = 0; 37 +static int gpio_mmap_size; 38 static unsigned int mmap_count = 0; 39 static int platform_detected = 0; 40 41 @@ -129,9 +132,10 @@ 42 } 43 44 mmap_reg = (uint8_t*) mmap(NULL, MT7628_BLOCK_SIZE, PROT_READ | PROT_WRITE, 45 - MAP_FILE | MAP_SHARED, mmap_fd, MT7628_GPIO_BASE); 46 + MAP_FILE | MAP_SHARED, mmap_fd, 0x10000000); 47 if (mmap_reg == MAP_FAILED) { 48 - syslog(LOG_ERR, "linkit mmap: failed to mmap"); 49 + perror("foo"); 50 + syslog(LOG_ERR, "linkit mmap: failed to mmap"); 51 mmap_reg = NULL; 52 close(mmap_fd); 53 return MRAA_ERROR_NO_RESOURCES; 54 @@ -144,201 +148,442 @@ 55 return MRAA_SUCCESS; 56 } 57 58 +static int mmap_gpiomode(void) 59 +{ 60 + if ((gpio_mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) { 61 + syslog(LOG_ERR, "linkit map: unable to open resource0 file"); 62 + return MRAA_ERROR_INVALID_HANDLE; 63 + } 64 + 65 + gpio_mmap_reg = (uint8_t*) mmap(NULL, MT7628_BLOCK_SIZE, PROT_READ | PROT_WRITE, 66 + MAP_FILE | MAP_SHARED, gpio_mmap_fd, MT7628_GPIOMODE_BASE); 67 + if (gpio_mmap_reg == MAP_FAILED) { 68 + syslog(LOG_ERR, "linkit gpio_mmap: failed to mmap"); 69 + gpio_mmap_reg = NULL; 70 + close(gpio_mmap_fd); 71 + return MRAA_ERROR_NO_RESOURCES; 72 + } 73 + return 0; 74 +} 75 + 76 +static void set_gpiomode(unsigned int mask, unsigned int shift, unsigned int val) 77 +{ 78 + unsigned int reg; 79 + unsigned int offset = 0x60; 80 + 81 + if (shift >= 32) { 82 + shift -= 32; 83 + offset += 4; 84 + } 85 + 86 + reg = *(volatile uint32_t*) (gpio_mmap_reg + offset); 87 + 88 + reg &= ~(mask << shift); 89 + reg |= (val << shift); 90 + *(volatile uint32_t*) (gpio_mmap_reg + offset) = reg; 91 +} 92 + 93 +enum { 94 + MUX_GPIO = 0, 95 + MUX_SPI_S, 96 + MUX_SPI_CS1, 97 + MUX_I2S, 98 + MUX_UART0, 99 + MUX_I2C, 100 + MUX_UART1, 101 + MUX_UART2, 102 + MUX_PWM0, 103 + MUX_PWM1, 104 + MUX_EPHY, 105 + MUX_WLED, 106 + __MUX_MAX, 107 +}; 108 + 109 +static unsigned char gpio_mux_groups[64]; 110 +static struct pinmux { 111 + char *name; 112 + char *func[4]; 113 + unsigned int shift; 114 + unsigned int mask; 115 +} mt7688_mux[] = { 116 + { 117 + .name = "refclk", 118 + .func = { "refclk", "gpio", NULL, NULL }, 119 + .shift = 18, 120 + .mask = 0x1, 121 + }, { 122 + .name = "spi_s", 123 + .func = { "spi_s", "gpio", "utif", "pwm" }, 124 + .shift = 2, 125 + .mask = 0x3, 126 + }, { 127 + .name = "spi_cs1", 128 + .func = { "spi_cs1", "gpio", NULL, "refclk" }, 129 + .shift = 4, 130 + .mask = 0x3, 131 + }, { 132 + .name = "i2s", 133 + .func = { "i2s", "gpio", "pcm", NULL }, 134 + .shift = 6, 135 + .mask = 0x3, 136 + }, { 137 + .name = "uart0", 138 + .func = { "uart", "gpio", NULL, NULL }, 139 + .shift = 8, 140 + .mask = 0x3, 141 + }, { 142 + .name = "i2c", 143 + .func = { "i2c", "gpio", NULL, NULL }, 144 + .shift = 20, 145 + .mask = 0x3, 146 + }, { 147 + .name = "uart1", 148 + .func = { "uart", "gpio", NULL, NULL }, 149 + .shift = 24, 150 + .mask = 0x3, 151 + }, { 152 + .name = "uart2", 153 + .func = { "uart", "gpio", "pwm", NULL }, 154 + .shift = 26, 155 + .mask = 0x3, 156 + }, { 157 + .name = "pwm0", 158 + .func = { "pwm", "gpio", NULL, NULL }, 159 + .shift = 28, 160 + .mask = 0x3, 161 + }, { 162 + .name = "pwm1", 163 + .func = { "pwm", "gpio", NULL, NULL }, 164 + .shift = 30, 165 + .mask = 0x3, 166 + }, { 167 + .name = "ephy", 168 + .func = { "ephy", "gpio", NULL, NULL }, 169 + .shift = 34, 170 + .mask = 0x3, 171 + }, { 172 + .name = "wled", 173 + .func = { "wled", "gpio", NULL, NULL }, 174 + .shift = 32, 175 + .mask = 0x3, 176 + }, 177 +}; 178 + 179 +mraa_result_t gpio_init_pre(int pin) 180 +{ 181 + struct pinmux *m = &mt7688_mux[gpio_mux_groups[pin]]; 182 + 183 + set_gpiomode(m->mask, m->shift, 1); 184 + 185 + return 0; 186 +} 187 + 188 +static void gpiomode_set(unsigned int id, char *name) 189 +{ 190 + int i; 191 + 192 + if (id >= __MUX_MAX) 193 + return; 194 + 195 + for (i = 0; i < 4; i++) { 196 + if (!mt7688_mux[id].func[i] || strcmp(mt7688_mux[id].func[i], name)) 197 + continue; 198 + set_gpiomode(mt7688_mux[id].mask, mt7688_mux[id].shift, i); 199 + syslog(0, "mraa: set pinmux %s -> %s\n", mt7688_mux[id].name, name); 200 + return; 201 + } 202 +} 203 + 204 +mraa_result_t i2c_init_pre(unsigned int bus) 205 +{ 206 + gpiomode_set(MUX_I2C, "i2c"); 207 + return 0; 208 +} 209 + 210 +mraa_result_t 211 +pwm_init_post(mraa_pwm_context pwm) 212 +{ 213 + switch(pwm->pin) { 214 + case 0: 215 + gpiomode_set(MUX_PWM0, "pwm"); 216 + break; 217 + case 1: 218 + gpiomode_set(MUX_PWM1, "pwm"); 219 + break; 220 + case 2: 221 + case 3: 222 + gpiomode_set(MUX_UART2, "pwm"); 223 + break; 224 + } 225 + return 0; 226 +} 227 + 228 +mraa_result_t spi_init_pre(int bus) 229 +{ 230 + gpiomode_set(MUX_SPI_CS1, "spi_cs1"); 231 + return 0; 232 +} 233 + 234 +mraa_result_t uart_init_pre(int index) 235 +{ 236 + switch(index) { 237 + case 0: 238 + gpiomode_set(MUX_UART0, "uart"); 239 + break; 240 + case 1: 241 + gpiomode_set(MUX_UART1, "uart"); 242 + break; 243 + case 2: 244 + gpiomode_set(MUX_UART2, "uart"); 245 + break; 246 + } 247 + return 0; 248 +} 249 + 250 +mraa_result_t 251 +i2c_freq(mraa_i2c_context dev, mraa_i2c_mode_t mode) 252 +{ 253 + switch (mode) { 254 + case MRAA_I2C_STD: 255 + break; 256 + default: 257 + syslog(LOG_ERR, "Invalid i2c frequency"); 258 + break; 259 + } 260 + return MRAA_SUCCESS; 261 +} 262 + 263 + 264 mraa_board_t* 265 mraa_mtk_linkit() 266 { 267 + int i; 268 + 269 + if (mmap_gpiomode()) 270 + return NULL; 271 + 272 mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t)); 273 if (b == NULL) { 274 return NULL; 275 } 276 277 - b->platform_name = "LINKIT"; 278 + memset(b, 0, sizeof(mraa_board_t)); 279 + 280 + b->platform_name = "LinkIt Smart 7688"; 281 platform_detected = PLATFORM_MEDIATEK_LINKIT; 282 - b->phy_pin_count = 31; 283 + b->phy_pin_count = 64; 284 285 b->aio_count = 0; 286 b->adc_raw = 0; 287 b->adc_supported = 0; 288 b->pwm_default_period = 500; 289 - b->pwm_max_period = 2147483; 290 + b->pwm_max_period = 1000000; 291 b->pwm_min_period = 1; 292 293 - b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count); 294 - 295 - advance_func->gpio_mmap_setup = &mraa_mtk_linkit_mmap_setup; 296 - 297 - strncpy(b->pins[0].name, "P0", MRAA_PIN_NAME_SIZE); 298 - b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 299 - 300 - strncpy(b->pins[1].name, "P1", MRAA_PIN_NAME_SIZE); 301 - b->pins[1].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 302 - 303 - strncpy(b->pins[2].name, "P2", MRAA_PIN_NAME_SIZE); 304 - b->pins[2].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 305 - 306 - strncpy(b->pins[3].name, "P3", MRAA_PIN_NAME_SIZE); 307 - b->pins[3].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 308 - 309 - strncpy(b->pins[4].name, "P4", MRAA_PIN_NAME_SIZE); 310 - b->pins[4].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 311 - 312 - strncpy(b->pins[5].name, "P5", MRAA_PIN_NAME_SIZE); 313 - b->pins[5].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 314 - 315 - strncpy(b->pins[6].name, "P6", MRAA_PIN_NAME_SIZE); 316 - b->pins[6].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 317 - 318 - strncpy(b->pins[7].name, "P7", MRAA_PIN_NAME_SIZE); 319 - b->pins[7].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 320 - 321 - strncpy(b->pins[8].name, "P8", MRAA_PIN_NAME_SIZE); 322 - b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 323 - b->pins[8].gpio.pinmap = 21; 324 - b->pins[8].uart.parent_id = 2; 325 - b->pins[8].uart.mux_total = 0; 326 + b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t)); 327 + if (b->adv_func == NULL) { 328 + return NULL; 329 + } 330 331 - strncpy(b->pins[9].name, "P9", MRAA_PIN_NAME_SIZE); 332 - b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 333 - b->pins[9].gpio.pinmap = 20; 334 - b->pins[9].uart.parent_id = 2; 335 - b->pins[9].uart.mux_total = 0; 336 + b->adv_func->i2c_init_pre = i2c_init_pre; 337 + b->adv_func->pwm_init_post = pwm_init_post; 338 + b->adv_func->spi_init_pre = spi_init_pre; 339 + b->adv_func->uart_init_pre = uart_init_pre; 340 + b->adv_func->gpio_init_pre = gpio_init_pre; 341 + b->adv_func->i2c_set_frequency_replace = &i2c_freq; 342 343 - strncpy(b->pins[10].name, "P10", MRAA_PIN_NAME_SIZE); 344 - b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 345 - b->pins[10].gpio.pinmap = 2; 346 + b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count); 347 348 - strncpy(b->pins[11].name, "P11", MRAA_PIN_NAME_SIZE); 349 - b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 350 - b->pins[11].gpio.pinmap = 3; 351 + memset(b->pins, 0, sizeof(mraa_pininfo_t) * b->phy_pin_count); 352 + memset(gpio_mux_groups, -1, sizeof(gpio_mux_groups)); 353 354 - strncpy(b->pins[12].name, "P12", MRAA_PIN_NAME_SIZE); 355 - b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 356 - b->pins[12].gpio.pinmap = 0; 357 + b->adv_func->gpio_mmap_setup = &mraa_mtk_linkit_mmap_setup; 358 359 - strncpy(b->pins[13].name, "P13", MRAA_PIN_NAME_SIZE); 360 - b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 361 - b->pins[13].gpio.pinmap = 1; 362 + for (i = 0; i < b->phy_pin_count; i++) { 363 + snprintf(b->pins[i].name, MRAA_PIN_NAME_SIZE, "GPIO%d", i); 364 + b->pins[i].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 365 + } 366 367 - strncpy(b->pins[14].name, "P14", MRAA_PIN_NAME_SIZE); 368 - b->pins[14].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }; 369 + strncpy(b->pins[43].name, "GPIO43", MRAA_PIN_NAME_SIZE); 370 + b->pins[43].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 371 + b->pins[43].gpio.pinmap = 43; 372 + gpio_mux_groups[43] = MUX_EPHY; 373 + 374 + strncpy(b->pins[20].name, "GPIO20", MRAA_PIN_NAME_SIZE); 375 + b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 1 }; 376 + b->pins[20].gpio.pinmap = 20; 377 + b->pins[20].uart.parent_id = 2; 378 + b->pins[20].uart.mux_total = 0; 379 + b->pins[20].pwm.parent_id = 0; 380 + b->pins[20].pwm.pinmap = 2; 381 + gpio_mux_groups[20] = MUX_UART2; 382 + 383 + strncpy(b->pins[21].name, "GPIO21", MRAA_PIN_NAME_SIZE); 384 + b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 1 }; 385 + b->pins[21].gpio.pinmap = 21; 386 + b->pins[21].uart.parent_id = 2; 387 + b->pins[21].uart.mux_total = 0; 388 + b->pins[21].pwm.parent_id = 0; 389 + b->pins[21].pwm.pinmap = 3; 390 + gpio_mux_groups[21] = MUX_UART2; 391 + 392 + strncpy(b->pins[2].name, "GPIO2", MRAA_PIN_NAME_SIZE); 393 + b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 394 + b->pins[2].gpio.pinmap = 2; 395 + gpio_mux_groups[2] = MUX_I2S; 396 + 397 + strncpy(b->pins[3].name, "GPIO3", MRAA_PIN_NAME_SIZE); 398 + b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 399 + b->pins[3].gpio.pinmap = 3; 400 + gpio_mux_groups[3] = MUX_I2S; 401 + 402 + strncpy(b->pins[0].name, "GPIO0", MRAA_PIN_NAME_SIZE); 403 + b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 404 + b->pins[0].gpio.pinmap = 0; 405 + gpio_mux_groups[0] = MUX_I2S; 406 + 407 + strncpy(b->pins[1].name, "GPIO1", MRAA_PIN_NAME_SIZE); 408 + b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 409 + b->pins[1].gpio.pinmap = 1; 410 + gpio_mux_groups[1] = MUX_I2S; 411 + 412 + strncpy(b->pins[37].name, "GPIO37", MRAA_PIN_NAME_SIZE); 413 + b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 414 + b->pins[37].gpio.pinmap = 37; 415 + gpio_mux_groups[37] = MUX_GPIO; 416 + 417 + strncpy(b->pins[44].name, "GPIO44", MRAA_PIN_NAME_SIZE); 418 + b->pins[44].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 419 + b->pins[44].gpio.pinmap = 44; 420 + gpio_mux_groups[44] = MUX_WLED; 421 + 422 + strncpy(b->pins[46].name, "GPIO46", MRAA_PIN_NAME_SIZE); 423 + b->pins[46].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 424 + b->pins[46].gpio.pinmap = 46; 425 + b->pins[46].uart.parent_id = 1; 426 + b->pins[46].uart.mux_total = 0; 427 + gpio_mux_groups[46] = MUX_UART1; 428 + 429 + strncpy(b->pins[45].name, "GPIO45", MRAA_PIN_NAME_SIZE); 430 + b->pins[45].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 431 + b->pins[45].gpio.pinmap = 45; 432 + b->pins[45].uart.parent_id = 1; 433 + b->pins[45].uart.mux_total = 0; 434 + gpio_mux_groups[45] = MUX_UART1; 435 + 436 + strncpy(b->pins[13].name, "GPIO13", MRAA_PIN_NAME_SIZE); 437 + b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 438 + b->pins[13].gpio.pinmap = 13; 439 + b->pins[13].uart.parent_id = 1; 440 + b->pins[13].uart.mux_total = 0; 441 + gpio_mux_groups[13] = MUX_UART0; 442 + 443 + strncpy(b->pins[12].name, "GPIO12", MRAA_PIN_NAME_SIZE); 444 + b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 445 + b->pins[12].gpio.pinmap = 12; 446 + b->pins[12].uart.parent_id = 0; 447 + b->pins[12].uart.mux_total = 0; 448 + gpio_mux_groups[12] = MUX_UART0; 449 + 450 + strncpy(b->pins[5].name, "GPIO5", MRAA_PIN_NAME_SIZE); 451 + b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; 452 + b->pins[5].gpio.pinmap = 5; 453 + b->pins[5].i2c.pinmap = 0; 454 + b->pins[5].i2c.mux_total = 0; 455 + gpio_mux_groups[5] = MUX_I2C; 456 + 457 + strncpy(b->pins[4].name, "GPIO4", MRAA_PIN_NAME_SIZE); 458 + b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; 459 + b->pins[4].gpio.pinmap = 4; 460 + b->pins[4].i2c.pinmap = 0; 461 + b->pins[4].i2c.mux_total = 0; 462 + gpio_mux_groups[4] = MUX_I2C; 463 + 464 + strncpy(b->pins[6].name, "GPIO6", MRAA_PIN_NAME_SIZE); 465 + b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; 466 + b->pins[6].gpio.pinmap = 6; 467 + b->pins[6].spi.pinmap = 0; 468 + b->pins[6].spi.mux_total = 0; 469 + gpio_mux_groups[6] = MUX_SPI_CS1; 470 + 471 + strncpy(b->pins[7].name, "GPIO7", MRAA_PIN_NAME_SIZE); 472 + b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }; 473 + b->pins[7].spi.pinmap = 0; 474 + b->pins[7].spi.mux_total = 0; 475 + 476 + strncpy(b->pins[8].name, "GPIO8", MRAA_PIN_NAME_SIZE); 477 + b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }; 478 + b->pins[8].spi.pinmap = 0; 479 + b->pins[8].spi.mux_total = 0; 480 + 481 + strncpy(b->pins[9].name, "GPIO9", MRAA_PIN_NAME_SIZE); 482 + b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }; 483 + b->pins[9].spi.pinmap = 0; 484 + b->pins[9].spi.mux_total = 0; 485 + 486 + strncpy(b->pins[18].name, "GPIO18", MRAA_PIN_NAME_SIZE); 487 + b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }; 488 + b->pins[18].gpio.pinmap = 18; 489 + b->pins[18].pwm.parent_id = 0; 490 + b->pins[18].pwm.pinmap = 0; 491 + gpio_mux_groups[18] = MUX_PWM0; 492 + 493 + strncpy(b->pins[19].name, "GPIO19", MRAA_PIN_NAME_SIZE); 494 + b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }; 495 + b->pins[19].gpio.pinmap = 19; 496 + b->pins[19].pwm.parent_id = 0; 497 + b->pins[19].pwm.pinmap = 1; 498 + gpio_mux_groups[19] = MUX_PWM1; 499 + 500 + strncpy(b->pins[16].name, "GPIO16", MRAA_PIN_NAME_SIZE); 501 + b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 502 + b->pins[16].gpio.pinmap = 16; 503 + gpio_mux_groups[16] = MUX_SPI_S; 504 + 505 + strncpy(b->pins[17].name, "GPIO17", MRAA_PIN_NAME_SIZE); 506 + b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 507 + b->pins[17].gpio.pinmap = 17; 508 + gpio_mux_groups[17] = MUX_SPI_S; 509 + 510 + strncpy(b->pins[14].name, "GPIO14", MRAA_PIN_NAME_SIZE); 511 + b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 512 + b->pins[14].gpio.pinmap = 14; 513 + gpio_mux_groups[14] = MUX_SPI_S; 514 515 - strncpy(b->pins[15].name, "P15", MRAA_PIN_NAME_SIZE); 516 + strncpy(b->pins[15].name, "GPIO15", MRAA_PIN_NAME_SIZE); 517 b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 518 - b->pins[15].gpio.pinmap = 44; 519 - 520 - strncpy(b->pins[16].name, "P16", MRAA_PIN_NAME_SIZE); 521 - b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 522 - b->pins[16].gpio.pinmap = 46; 523 - b->pins[16].uart.parent_id = 1; 524 - b->pins[16].uart.mux_total = 0; 525 - 526 - strncpy(b->pins[17].name, "P17", MRAA_PIN_NAME_SIZE); 527 - b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 528 - b->pins[17].gpio.pinmap = 45; 529 - b->pins[17].uart.parent_id = 1; 530 - b->pins[17].uart.mux_total = 0; 531 - 532 - strncpy(b->pins[18].name, "P18", MRAA_PIN_NAME_SIZE); 533 - b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 534 - b->pins[18].gpio.pinmap = 13; 535 - b->pins[18].uart.parent_id = 1; 536 - b->pins[18].uart.mux_total = 0; 537 - 538 - strncpy(b->pins[19].name, "P19", MRAA_PIN_NAME_SIZE); 539 - b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; 540 - b->pins[19].gpio.pinmap = 12; 541 - b->pins[19].uart.parent_id = 0; 542 - b->pins[19].uart.mux_total = 0; 543 - 544 - strncpy(b->pins[20].name, "P20", MRAA_PIN_NAME_SIZE); 545 - b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; 546 - b->pins[20].gpio.pinmap = 5; 547 - b->pins[20].i2c.pinmap = 0; 548 - b->pins[20].i2c.mux_total = 0; 549 - 550 - strncpy(b->pins[21].name, "P21", MRAA_PIN_NAME_SIZE); 551 - b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; 552 - b->pins[21].gpio.pinmap = 4; 553 - b->pins[21].i2c.pinmap = 0; 554 - b->pins[21].i2c.mux_total = 0; 555 - 556 - strncpy(b->pins[22].name, "P22", MRAA_PIN_NAME_SIZE); 557 - b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; 558 - b->pins[22].gpio.pinmap = 8; 559 - b->pins[22].spi.pinmap = 0; 560 - b->pins[22].spi.mux_total = 0; 561 - 562 - strncpy(b->pins[23].name, "P23", MRAA_PIN_NAME_SIZE); 563 - b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; 564 - b->pins[23].gpio.pinmap = 9; 565 - b->pins[23].spi.pinmap = 0; 566 - b->pins[23].spi.mux_total = 0; 567 - 568 - strncpy(b->pins[24].name, "P24", MRAA_PIN_NAME_SIZE); 569 - b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; 570 - b->pins[24].gpio.pinmap = 7; 571 - b->pins[24].spi.pinmap = 0; 572 - b->pins[24].spi.mux_total = 0; 573 - 574 - strncpy(b->pins[25].name, "P25", MRAA_PIN_NAME_SIZE); 575 - b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; 576 - b->pins[25].gpio.pinmap = 6; 577 - b->pins[25].spi.pinmap = 0; 578 - b->pins[25].spi.mux_total = 0; 579 - 580 - strncpy(b->pins[26].name, "P26", MRAA_PIN_NAME_SIZE); 581 - b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }; 582 - b->pins[26].gpio.pinmap = 18; 583 - 584 - strncpy(b->pins[27].name, "P27", MRAA_PIN_NAME_SIZE); 585 - b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 }; 586 - b->pins[27].gpio.pinmap = 19; 587 - 588 - strncpy(b->pins[28].name, "P28", MRAA_PIN_NAME_SIZE); 589 - b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 590 - b->pins[28].gpio.pinmap = 16; 591 - 592 - strncpy(b->pins[29].name, "P29", MRAA_PIN_NAME_SIZE); 593 - b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 594 - b->pins[29].gpio.pinmap = 17; 595 - 596 - strncpy(b->pins[30].name, "P30", MRAA_PIN_NAME_SIZE); 597 - b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 598 - b->pins[30].gpio.pinmap = 14; 599 - 600 - strncpy(b->pins[31].name, "P31", MRAA_PIN_NAME_SIZE); 601 - b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; 602 - b->pins[31].gpio.pinmap = 15; 603 + b->pins[15].gpio.pinmap = 15; 604 + gpio_mux_groups[15] = MUX_SPI_S; 605 606 // BUS DEFINITIONS 607 b->i2c_bus_count = 1; 608 b->def_i2c_bus = 0; 609 - b->i2c_bus[0].bus_id = 0; 610 - b->i2c_bus[0].sda = 20; 611 - b->i2c_bus[0].scl = 21; 612 + b->i2c_bus[0].bus_id = 0; 613 + b->i2c_bus[0].sda = 5; 614 + b->i2c_bus[0].scl = 4; 615 616 b->spi_bus_count = 1; 617 b->def_spi_bus = 0; 618 - b->spi_bus[0].bus_id = 0; 619 - b->spi_bus[0].slave_s = 0; 620 - b->spi_bus[0].cs = 25; 621 - b->spi_bus[0].mosi = 22; 622 - b->spi_bus[0].miso = 23; 623 - b->spi_bus[0].sclk = 21; 624 + b->spi_bus[0].bus_id = 32766; 625 + b->spi_bus[0].slave_s = 1; 626 + b->spi_bus[0].cs = 6; 627 + b->spi_bus[0].mosi = 8; 628 + b->spi_bus[0].miso = 9; 629 + b->spi_bus[0].sclk = 7; 630 631 b->uart_dev_count = 3; 632 b->def_uart_dev = 0; 633 - b->uart_dev[0].rx = 18; 634 - b->uart_dev[0].tx = 19; 635 - 636 - b->uart_dev[1].rx = 16; 637 - b->uart_dev[1].tx = 17; 638 - 639 - b->uart_dev[2].rx = 9; 640 - b->uart_dev[2].tx = 8; 641 + b->uart_dev[0].rx = 13; 642 + b->uart_dev[0].tx = 12; 643 + b->uart_dev[0].device_path = "/dev/ttyS0"; 644 + b->uart_dev[1].rx = 46; 645 + b->uart_dev[1].tx = 45; 646 + b->uart_dev[1].device_path = "/dev/ttyS1"; 647 + b->uart_dev[2].rx = 21; 648 + b->uart_dev[2].tx = 20; 649 + b->uart_dev[2].device_path = "/dev/ttyS2"; 650 651 b->gpio_count = 0; 652 - int i; 653 for (i = 0; i < b->phy_pin_count; i++) { 654 if (b->pins[i].capabilites.gpio) { 655 b->gpio_count++; 656 --- a/src/gpio/gpio.c 657 +++ b/src/gpio/gpio.c 658 @@ -113,6 +113,8 @@ 659 close(export); 660 } 661 662 + mraa_gpio_use_mmaped(dev, 1); 663 + 664 init_internal_cleanup: 665 if (status != MRAA_SUCCESS) { 666 if (dev != NULL)