paul@0 | 1 | /* |
paul@0 | 2 | * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de> |
paul@0 | 3 | * economic rights: Technische Universit??t Dresden (Germany) |
paul@54 | 4 | * Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 5 | * |
paul@0 | 6 | * This file is part of TUD:OS and distributed under the terms of the |
paul@0 | 7 | * GNU General Public License 2. |
paul@0 | 8 | * Please see the COPYING-GPL-2 file for details. |
paul@0 | 9 | */ |
paul@0 | 10 | /* |
paul@0 | 11 | * Access the I2C peripherals on the MIPS Creator CI20 board. |
paul@0 | 12 | */ |
paul@0 | 13 | |
paul@0 | 14 | #include <l4/devices/cpm-jz4780.h> |
paul@0 | 15 | #include <l4/devices/gpio-jz4780.h> |
paul@0 | 16 | #include <l4/devices/i2c-jz4780.h> |
paul@54 | 17 | #include <l4/devices/memory.h> |
paul@0 | 18 | #include <l4/io/io.h> |
paul@0 | 19 | #include <l4/libedid/edid.h> |
paul@0 | 20 | #include <l4/re/env.h> |
paul@0 | 21 | #include <l4/re/c/util/cap_alloc.h> |
paul@0 | 22 | #include <l4/sys/factory.h> |
paul@0 | 23 | #include <l4/sys/icu.h> |
paul@0 | 24 | #include <l4/sys/ipc.h> |
paul@0 | 25 | #include <l4/sys/irq.h> |
paul@54 | 26 | #include <l4/sys/rcv_endpoint.h> |
paul@0 | 27 | #include <l4/vbus/vbus.h> |
paul@0 | 28 | #include <stdio.h> |
paul@0 | 29 | #include <unistd.h> |
paul@0 | 30 | #include <stdint.h> |
paul@56 | 31 | #include <string.h> |
paul@0 | 32 | |
paul@0 | 33 | |
paul@0 | 34 | |
paul@0 | 35 | enum { |
paul@54 | 36 | PMSDA = 30, /* via PORTD */ |
paul@54 | 37 | PMSCL = 31, /* via PORTD */ |
paul@54 | 38 | PWM3 = 3, /* via PORTE */ |
paul@54 | 39 | PWM4 = 4, /* via PORTE */ |
paul@54 | 40 | RTCSDA = 12, /* via PORTE */ |
paul@54 | 41 | RTCSCL = 13, /* via PORTE */ |
paul@0 | 42 | DDCSCL = 24, /* via PORTF */ |
paul@0 | 43 | DDCSDA = 25, /* via PORTF */ |
paul@0 | 44 | }; |
paul@0 | 45 | |
paul@0 | 46 | |
paul@0 | 47 | |
paul@0 | 48 | /* Device and resource discovery. */ |
paul@0 | 49 | |
paul@0 | 50 | static long item_in_range(long start, long end, long index) |
paul@0 | 51 | { |
paul@0 | 52 | if (start < end) |
paul@0 | 53 | return start + index; |
paul@0 | 54 | else |
paul@0 | 55 | return start - index; |
paul@0 | 56 | } |
paul@0 | 57 | |
paul@0 | 58 | static void show_deviceid(uint8_t buf[]) |
paul@0 | 59 | { |
paul@0 | 60 | printf("Manufacturer %x part %x revision %x\n", |
paul@0 | 61 | (buf[0] << 4) | (buf[1] >> 4), |
paul@0 | 62 | ((buf[1] & 0xf) << 5) | (buf[2] >> 3), |
paul@0 | 63 | buf[2] & 0x7); |
paul@0 | 64 | } |
paul@0 | 65 | |
paul@0 | 66 | static void show_data(uint8_t buf[], unsigned pos) |
paul@0 | 67 | { |
paul@0 | 68 | unsigned i; |
paul@0 | 69 | |
paul@0 | 70 | if (pos) |
paul@0 | 71 | { |
paul@0 | 72 | printf("Read %d bytes from bus.\n", pos); |
paul@0 | 73 | for (i = 0; i < pos; i++) |
paul@0 | 74 | printf(" %02x", buf[i]); |
paul@0 | 75 | printf("\n"); |
paul@0 | 76 | } |
paul@0 | 77 | else |
paul@0 | 78 | printf("No reply from bus.\n"); |
paul@0 | 79 | } |
paul@0 | 80 | |
paul@56 | 81 | static long i2c_read(void *i2c_channel, uint8_t *buf, unsigned length, |
paul@56 | 82 | l4_cap_idx_t irqcap) |
paul@54 | 83 | { |
paul@54 | 84 | l4_msgtag_t tag; |
paul@54 | 85 | long err; |
paul@54 | 86 | |
paul@54 | 87 | jz4780_i2c_start_read(i2c_channel, buf, length); |
paul@54 | 88 | |
paul@54 | 89 | while (!jz4780_i2c_read_done(i2c_channel)) |
paul@54 | 90 | { |
paul@54 | 91 | tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_rel(1, 20))); |
paul@54 | 92 | |
paul@54 | 93 | if ((err = l4_ipc_error(tag, l4_utcb()))) |
paul@56 | 94 | return err; |
paul@56 | 95 | |
paul@56 | 96 | if (jz4780_i2c_failed(i2c_channel)) |
paul@56 | 97 | return 0; |
paul@54 | 98 | |
paul@54 | 99 | jz4780_i2c_read(i2c_channel); |
paul@54 | 100 | } |
paul@54 | 101 | |
paul@54 | 102 | return jz4780_i2c_have_read(i2c_channel); |
paul@54 | 103 | } |
paul@54 | 104 | |
paul@56 | 105 | static long i2c_write(void *i2c_channel, uint8_t *buf, unsigned length, |
paul@56 | 106 | l4_cap_idx_t irqcap) |
paul@56 | 107 | { |
paul@56 | 108 | l4_msgtag_t tag; |
paul@56 | 109 | long err; |
paul@56 | 110 | |
paul@56 | 111 | jz4780_i2c_start_write(i2c_channel, buf, length); |
paul@56 | 112 | |
paul@56 | 113 | while (!jz4780_i2c_write_done(i2c_channel)) |
paul@56 | 114 | { |
paul@56 | 115 | tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_rel(1, 20))); |
paul@56 | 116 | |
paul@56 | 117 | if ((err = l4_ipc_error(tag, l4_utcb()))) |
paul@56 | 118 | return err; |
paul@56 | 119 | |
paul@56 | 120 | if (jz4780_i2c_failed(i2c_channel)) |
paul@56 | 121 | return 0; |
paul@56 | 122 | |
paul@56 | 123 | jz4780_i2c_write(i2c_channel); |
paul@56 | 124 | } |
paul@56 | 125 | |
paul@56 | 126 | return jz4780_i2c_have_written(i2c_channel); |
paul@56 | 127 | } |
paul@56 | 128 | |
paul@58 | 129 | static long i2c_get(void *i2c_channel, uint8_t reg, uint8_t *buffer, long length, l4_cap_idx_t irqcap) |
paul@58 | 130 | { |
paul@58 | 131 | long pos; |
paul@58 | 132 | |
paul@58 | 133 | buffer[0] = reg; |
paul@58 | 134 | i2c_write(i2c_channel, buffer, 1, irqcap); |
paul@58 | 135 | |
paul@58 | 136 | memset(buffer, 0, length); |
paul@58 | 137 | pos = i2c_read(i2c_channel, buffer, length, irqcap); |
paul@58 | 138 | |
paul@58 | 139 | jz4780_i2c_stop(i2c_channel); |
paul@58 | 140 | |
paul@58 | 141 | return pos; |
paul@58 | 142 | } |
paul@58 | 143 | |
paul@58 | 144 | static void i2c_report(void *i2c_channel, uint8_t *buffer, long length) |
paul@58 | 145 | { |
paul@58 | 146 | if (!jz4780_i2c_failed(i2c_channel)) |
paul@58 | 147 | { |
paul@58 | 148 | printf("Read: "); |
paul@58 | 149 | while (length--) |
paul@58 | 150 | printf("%02x", *(buffer++)); |
paul@58 | 151 | printf("\n"); |
paul@58 | 152 | } |
paul@58 | 153 | else |
paul@58 | 154 | printf("Read failed.\n"); |
paul@58 | 155 | } |
paul@58 | 156 | |
paul@54 | 157 | static void i2c_scan(void *i2c_channel, l4_cap_idx_t irqcap) |
paul@54 | 158 | { |
paul@54 | 159 | uint8_t buf[1]; |
paul@54 | 160 | unsigned int address; |
paul@54 | 161 | |
paul@54 | 162 | for (address = 0; address < 0x20; address++) |
paul@54 | 163 | printf("%02x ", address); |
paul@54 | 164 | printf("\n"); |
paul@54 | 165 | |
paul@54 | 166 | for (address = 0; address < 0x20; address++) |
paul@54 | 167 | printf("-- "); |
paul@54 | 168 | |
paul@54 | 169 | for (address = 0; address < 0x80; address++) |
paul@54 | 170 | { |
paul@54 | 171 | if ((address % 32) == 0) |
paul@54 | 172 | printf("\n"); |
paul@54 | 173 | |
paul@54 | 174 | jz4780_i2c_set_target(i2c_channel, address); |
paul@58 | 175 | i2c_get(i2c_channel, 0, buf, 1, irqcap); |
paul@54 | 176 | |
paul@56 | 177 | if (!jz4780_i2c_failed(i2c_channel)) |
paul@54 | 178 | printf("%02x ", address); |
paul@54 | 179 | else |
paul@54 | 180 | printf("?? "); |
paul@54 | 181 | } |
paul@54 | 182 | |
paul@54 | 183 | printf("\n"); |
paul@54 | 184 | for (address = 0; address < 0x20; address++) |
paul@54 | 185 | printf("-- "); |
paul@54 | 186 | printf("\n\n"); |
paul@54 | 187 | } |
paul@54 | 188 | |
paul@54 | 189 | static void ddc_read(void *i2c_channel, l4_cap_idx_t irqcap) |
paul@54 | 190 | { |
paul@54 | 191 | /* Buffer for reading. */ |
paul@54 | 192 | |
paul@54 | 193 | uint8_t buf[128]; |
paul@56 | 194 | long pos; |
paul@54 | 195 | |
paul@54 | 196 | /* DDC EDID details. */ |
paul@54 | 197 | |
paul@54 | 198 | unsigned width = 0, height = 0; |
paul@54 | 199 | |
paul@54 | 200 | printf("Trying DDC on I2C4...\n"); |
paul@54 | 201 | |
paul@54 | 202 | /* Attempt to read from address 0x50 for DDC. |
paul@54 | 203 | See: drivers/video/fbdev/core/fb_ddc.c */ |
paul@54 | 204 | |
paul@54 | 205 | jz4780_i2c_set_target(i2c_channel, 0x50); |
paul@58 | 206 | pos = i2c_get(i2c_channel, 0, buf, 128, irqcap); |
paul@54 | 207 | |
paul@56 | 208 | if (pos <= 0) |
paul@56 | 209 | { |
paul@56 | 210 | printf("Read failed.\n"); |
paul@56 | 211 | return; |
paul@56 | 212 | } |
paul@54 | 213 | |
paul@54 | 214 | show_data(buf, pos); |
paul@54 | 215 | |
paul@54 | 216 | /* Attempt to decode EDID information. */ |
paul@54 | 217 | |
paul@54 | 218 | libedid_prefered_resolution(buf, &width, &height); |
paul@54 | 219 | printf("Preferred resolution: %d x %d\n", width, height); |
paul@54 | 220 | |
paul@54 | 221 | libedid_dump_standard_timings(buf); |
paul@54 | 222 | } |
paul@54 | 223 | |
paul@54 | 224 | static void pmic_out3_control(void *i2c_channel, l4_cap_idx_t irqcap) |
paul@54 | 225 | { |
paul@54 | 226 | /* Buffer for communicating. */ |
paul@54 | 227 | |
paul@54 | 228 | uint8_t buf[2]; |
paul@54 | 229 | |
paul@54 | 230 | /* Attempt to read from address 0x5a for PMIC OUT3. */ |
paul@54 | 231 | |
paul@54 | 232 | jz4780_i2c_set_target(i2c_channel, 0x5a); |
paul@58 | 233 | i2c_get(i2c_channel, 0x32, buf, 1, irqcap); |
paul@58 | 234 | i2c_report(i2c_channel, buf, 1); |
paul@54 | 235 | |
paul@54 | 236 | #if 0 |
paul@54 | 237 | /* Disable the regulator. */ |
paul@54 | 238 | |
paul@54 | 239 | printf("Updating...\n"); |
paul@56 | 240 | |
paul@54 | 241 | buf[1] = buf[0] & ~0x80; |
paul@54 | 242 | buf[0] = 0x32; |
paul@56 | 243 | i2c_write(i2c_channel, buf, 2, irqcap); |
paul@56 | 244 | jz4780_i2c_stop(i2c_channel); |
paul@54 | 245 | |
paul@54 | 246 | /* Read back from the register. Seemed to give 0xff, which makes no real |
paul@54 | 247 | sense, although the regulator did bring the voltage level low. */ |
paul@54 | 248 | |
paul@58 | 249 | i2c_get(i2c_channel, 0x32, buf, 1, irqcap); |
paul@58 | 250 | i2c_report(i2c_channel, buf, 1); |
paul@58 | 251 | #endif |
paul@58 | 252 | } |
paul@56 | 253 | |
paul@58 | 254 | static void rtc_control(void *i2c_channel, l4_cap_idx_t irqcap) |
paul@58 | 255 | { |
paul@58 | 256 | /* Buffer for communicating. */ |
paul@58 | 257 | |
paul@58 | 258 | uint8_t buf[1]; |
paul@58 | 259 | |
paul@58 | 260 | /* Attempt to read from address 0x51 for RTC. */ |
paul@58 | 261 | |
paul@58 | 262 | jz4780_i2c_set_target(i2c_channel, 0x51); |
paul@58 | 263 | i2c_get(i2c_channel, 0x0f, buf, 1, irqcap); |
paul@58 | 264 | i2c_report(i2c_channel, buf, 1); |
paul@54 | 265 | } |
paul@54 | 266 | |
paul@0 | 267 | int main(void) |
paul@0 | 268 | { |
paul@54 | 269 | long err; |
paul@54 | 270 | |
paul@54 | 271 | /* Peripheral memory. */ |
paul@54 | 272 | |
paul@0 | 273 | l4_addr_t gpio_base = 0, gpio_base_end = 0; |
paul@54 | 274 | l4_addr_t i2c_base = 0, i2c_base_end = 0; |
paul@54 | 275 | l4_addr_t cpm_base = 0, cpm_base_end = 0; |
paul@54 | 276 | l4_addr_t port_d, port_d_end; |
paul@54 | 277 | l4_addr_t port_e, port_e_end; |
paul@0 | 278 | l4_addr_t port_f, port_f_end; |
paul@54 | 279 | |
paul@54 | 280 | /* Peripheral abstractions. */ |
paul@54 | 281 | |
paul@54 | 282 | void *gpio_port_d, *gpio_port_e, *gpio_port_f; |
paul@54 | 283 | void *i2c, *cpm; |
paul@54 | 284 | void *i2c0, *i2c4; |
paul@54 | 285 | |
paul@54 | 286 | /* IRQ resources. */ |
paul@54 | 287 | |
paul@54 | 288 | l4_uint32_t i2c_irq_start = 0, i2c_irq_end = 0; |
paul@54 | 289 | l4_cap_idx_t icucap, irq0cap, irq4cap; |
paul@0 | 290 | |
paul@0 | 291 | /* Obtain capabilities for the interrupt controller and an interrupt. */ |
paul@0 | 292 | |
paul@54 | 293 | irq0cap = l4re_util_cap_alloc(); |
paul@54 | 294 | irq4cap = l4re_util_cap_alloc(); |
paul@0 | 295 | icucap = l4re_env_get_cap("icu"); |
paul@0 | 296 | |
paul@0 | 297 | if (l4_is_invalid_cap(icucap)) |
paul@0 | 298 | { |
paul@0 | 299 | printf("No 'icu' capability available in the virtual bus.\n"); |
paul@0 | 300 | return 1; |
paul@0 | 301 | } |
paul@0 | 302 | |
paul@54 | 303 | if (l4_is_invalid_cap(irq0cap) || l4_is_invalid_cap(irq4cap)) |
paul@0 | 304 | { |
paul@54 | 305 | printf("Capabilities not available for interrupts.\n"); |
paul@0 | 306 | return 1; |
paul@0 | 307 | } |
paul@0 | 308 | |
paul@0 | 309 | /* Obtain resource details describing the interrupt for I2C channel 4. */ |
paul@0 | 310 | |
paul@0 | 311 | printf("Access IRQ...\n"); |
paul@0 | 312 | |
paul@54 | 313 | if (get_irq("jz4780-i2c", &i2c_irq_start, &i2c_irq_end) < 0) |
paul@0 | 314 | return 1; |
paul@0 | 315 | |
paul@0 | 316 | printf("IRQ range at %d...%d.\n", i2c_irq_start, i2c_irq_end); |
paul@0 | 317 | |
paul@0 | 318 | /* Obtain resource details describing I/O memory. */ |
paul@0 | 319 | |
paul@0 | 320 | printf("Access GPIO...\n"); |
paul@0 | 321 | |
paul@54 | 322 | if (get_memory("jz4780-gpio", &gpio_base, &gpio_base_end) < 0) |
paul@0 | 323 | return 1; |
paul@0 | 324 | |
paul@0 | 325 | printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); |
paul@0 | 326 | |
paul@0 | 327 | printf("Access CPM...\n"); |
paul@0 | 328 | |
paul@54 | 329 | if (get_memory("jz4780-cpm", &cpm_base, &cpm_base_end) < 0) |
paul@0 | 330 | return 1; |
paul@0 | 331 | |
paul@0 | 332 | printf("CPM at 0x%lx...0x%lx.\n", cpm_base, cpm_base_end); |
paul@0 | 333 | |
paul@0 | 334 | printf("Access I2C...\n"); |
paul@0 | 335 | |
paul@54 | 336 | if (get_memory("jz4780-i2c", &i2c_base, &i2c_base_end) < 0) |
paul@0 | 337 | return 1; |
paul@0 | 338 | |
paul@0 | 339 | printf("I2C at 0x%lx...0x%lx.\n", i2c_base, i2c_base_end); |
paul@0 | 340 | |
paul@54 | 341 | /* Create interrupt objects. */ |
paul@0 | 342 | |
paul@54 | 343 | err = l4_error(l4_factory_create_irq(l4re_global_env->factory, irq0cap)) || |
paul@54 | 344 | l4_error(l4_factory_create_irq(l4re_global_env->factory, irq4cap)); |
paul@54 | 345 | |
paul@54 | 346 | if (err) |
paul@0 | 347 | { |
paul@0 | 348 | printf("Could not create IRQ object: %lx\n", err); |
paul@0 | 349 | return 1; |
paul@0 | 350 | } |
paul@0 | 351 | |
paul@54 | 352 | /* Bind interrupt objects to IRQ numbers. */ |
paul@0 | 353 | |
paul@54 | 354 | err = l4_error(l4_icu_bind(icucap, |
paul@54 | 355 | item_in_range(i2c_irq_start, i2c_irq_end, 0), |
paul@54 | 356 | irq0cap)) || |
paul@54 | 357 | l4_error(l4_icu_bind(icucap, |
paul@54 | 358 | item_in_range(i2c_irq_start, i2c_irq_end, 4), |
paul@54 | 359 | irq4cap)); |
paul@54 | 360 | |
paul@54 | 361 | if (err) |
paul@0 | 362 | { |
paul@54 | 363 | printf("Could not bind IRQ to the ICU: %ld\n", err); |
paul@0 | 364 | return 1; |
paul@0 | 365 | } |
paul@0 | 366 | |
paul@0 | 367 | /* Attach ourselves to the interrupt handler. */ |
paul@0 | 368 | |
paul@54 | 369 | err = l4_error(l4_rcv_ep_bind_thread(irq0cap, l4re_env()->main_thread, 0)) || |
paul@54 | 370 | l4_error(l4_rcv_ep_bind_thread(irq4cap, l4re_env()->main_thread, 4)); |
paul@0 | 371 | |
paul@54 | 372 | if (err) |
paul@0 | 373 | { |
paul@54 | 374 | printf("Could not attach to IRQs: %ld\n", err); |
paul@0 | 375 | return 1; |
paul@0 | 376 | } |
paul@0 | 377 | |
paul@0 | 378 | /* Configure pins. */ |
paul@0 | 379 | |
paul@54 | 380 | port_d = gpio_base + 0x300; |
paul@54 | 381 | port_d_end = port_d + 0x100; |
paul@54 | 382 | port_e = gpio_base + 0x400; |
paul@54 | 383 | port_e_end = port_e + 0x100; |
paul@0 | 384 | port_f = gpio_base + 0x500; |
paul@0 | 385 | port_f_end = port_f + 0x100; |
paul@0 | 386 | |
paul@54 | 387 | printf("PORTD at 0x%lx...0x%lx.\n", port_d, port_d_end); |
paul@54 | 388 | printf("PORTE at 0x%lx...0x%lx.\n", port_e, port_e_end); |
paul@0 | 389 | printf("PORTF at 0x%lx...0x%lx.\n", port_f, port_f_end); |
paul@0 | 390 | |
paul@54 | 391 | gpio_port_d = jz4780_gpio_init(port_d, port_d_end, 32, 0xffff4fff, 0x0000b000); |
paul@54 | 392 | gpio_port_e = jz4780_gpio_init(port_e, port_e_end, 32, 0xfffff37c, 0x00000483); |
paul@54 | 393 | gpio_port_f = jz4780_gpio_init(port_f, port_f_end, 32, 0x7fa7f00f, 0x00580ff0); |
paul@0 | 394 | |
paul@0 | 395 | printf("Set up GPIO pins...\n"); |
paul@0 | 396 | |
paul@54 | 397 | jz4780_gpio_config_pad(gpio_port_d, PMSCL, Function_alt, 0); |
paul@54 | 398 | jz4780_gpio_config_pad(gpio_port_d, PMSDA, Function_alt, 0); |
paul@54 | 399 | |
paul@58 | 400 | //jz4780_gpio_config_pad(gpio_port_e, RTCSCL, Function_alt, 1); |
paul@58 | 401 | //jz4780_gpio_config_pad(gpio_port_e, RTCSDA, Function_alt, 1); |
paul@54 | 402 | |
paul@0 | 403 | jz4780_gpio_config_pad(gpio_port_f, DDCSCL, Function_alt, 1); |
paul@0 | 404 | jz4780_gpio_config_pad(gpio_port_f, DDCSDA, Function_alt, 1); |
paul@0 | 405 | |
paul@0 | 406 | /* Obtain CPM and I2C objects. */ |
paul@0 | 407 | |
paul@0 | 408 | cpm = jz4780_cpm_init(cpm_base); |
paul@0 | 409 | |
paul@0 | 410 | /* Attempt to set the PCLK source to SCLK_A. */ |
paul@0 | 411 | |
paul@0 | 412 | jz4780_cpm_set_pclock_source(cpm, 1); |
paul@0 | 413 | printf("Peripheral clock: %d\n", jz4780_cpm_get_pclock_frequency(cpm)); |
paul@0 | 414 | |
paul@0 | 415 | /* Obtain I2C reference. */ |
paul@0 | 416 | |
paul@0 | 417 | i2c = jz4780_i2c_init(i2c_base, i2c_base_end, cpm, 100000); /* 100 kHz */ |
paul@54 | 418 | i2c0 = jz4780_i2c_get_channel(i2c, 0); |
paul@54 | 419 | i2c4 = jz4780_i2c_get_channel(i2c, 4); |
paul@0 | 420 | |
paul@54 | 421 | printf("Scan I2C0...\n"); |
paul@54 | 422 | i2c_scan(i2c0, irq0cap); |
paul@0 | 423 | |
paul@54 | 424 | printf("Scan I2C4...\n"); |
paul@54 | 425 | i2c_scan(i2c4, irq4cap); |
paul@54 | 426 | |
paul@54 | 427 | pmic_out3_control(i2c0, irq0cap); |
paul@0 | 428 | |
paul@54 | 429 | ddc_read(i2c4, irq4cap); |
paul@0 | 430 | |
paul@58 | 431 | //rtc_control(i2c4, irq4cap); |
paul@58 | 432 | |
paul@54 | 433 | jz4780_i2c_disable(i2c0); |
paul@54 | 434 | jz4780_i2c_disable(i2c4); |
paul@0 | 435 | |
paul@0 | 436 | /* Detach from the interrupt. */ |
paul@0 | 437 | |
paul@54 | 438 | err = l4_error(l4_irq_detach(irq0cap)) || l4_error(l4_irq_detach(irq4cap)); |
paul@0 | 439 | |
paul@54 | 440 | if (err) |
paul@54 | 441 | printf("Error detaching from IRQ objects: %ld\n", err); |
paul@54 | 442 | |
paul@54 | 443 | printf("Done.\n"); |
paul@0 | 444 | |
paul@0 | 445 | return 0; |
paul@0 | 446 | } |