paul@62 | 1 | /* |
paul@62 | 2 | * JZ4780 HDMI peripheral support. |
paul@62 | 3 | * |
paul@62 | 4 | * Copyright (C) 2020 Paul Boddie <paul@boddie.org.uk> |
paul@62 | 5 | * |
paul@62 | 6 | * This program is free software; you can redistribute it and/or |
paul@62 | 7 | * modify it under the terms of the GNU General Public License as |
paul@62 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@62 | 9 | * the License, or (at your option) any later version. |
paul@62 | 10 | * |
paul@62 | 11 | * This program is distributed in the hope that it will be useful, |
paul@62 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@62 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@62 | 14 | * GNU General Public License for more details. |
paul@62 | 15 | * |
paul@62 | 16 | * You should have received a copy of the GNU General Public License |
paul@62 | 17 | * along with this program; if not, write to the Free Software |
paul@62 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@62 | 19 | * Boston, MA 02110-1301, USA |
paul@62 | 20 | */ |
paul@62 | 21 | |
paul@62 | 22 | #pragma once |
paul@62 | 23 | |
paul@62 | 24 | #include <l4/sys/types.h> |
paul@62 | 25 | #include <stdint.h> |
paul@62 | 26 | |
paul@62 | 27 | |
paul@62 | 28 | |
paul@62 | 29 | #ifdef __cplusplus |
paul@62 | 30 | |
paul@62 | 31 | #include <l4/devices/hw_mmio_register_block.h> |
paul@62 | 32 | |
paul@62 | 33 | // HDMI device control. |
paul@62 | 34 | |
paul@62 | 35 | class Hdmi_jz4780_chip |
paul@62 | 36 | { |
paul@62 | 37 | private: |
paul@62 | 38 | l4_addr_t _start, _end; |
paul@62 | 39 | l4_cap_idx_t _irq; |
paul@62 | 40 | Hw::Register_block<8> _regs; |
paul@62 | 41 | |
paul@62 | 42 | // Identification. |
paul@62 | 43 | |
paul@62 | 44 | uint16_t _version; |
paul@62 | 45 | |
paul@62 | 46 | // Transfer properties. |
paul@62 | 47 | |
paul@62 | 48 | bool _segment_read; |
paul@62 | 49 | uint8_t _device_register; |
paul@62 | 50 | |
paul@62 | 51 | protected: |
paul@62 | 52 | void get_identification(); |
paul@62 | 53 | |
paul@62 | 54 | void int_init(); |
paul@62 | 55 | |
paul@62 | 56 | void i2c_init(); |
paul@62 | 57 | long i2c_wait(); |
paul@62 | 58 | |
paul@62 | 59 | public: |
paul@62 | 60 | Hdmi_jz4780_chip(l4_addr_t start, l4_addr_t end, l4_cap_idx_t irq); |
paul@62 | 61 | |
paul@62 | 62 | void get_version(uint8_t *major, uint16_t *minor); |
paul@62 | 63 | |
paul@62 | 64 | int i2c_read(uint8_t *buf, unsigned int length); |
paul@62 | 65 | void i2c_set_address(uint8_t address); |
paul@62 | 66 | void i2c_set_segment(uint8_t segment); |
paul@62 | 67 | void i2c_set_register(uint8_t device_register); |
paul@62 | 68 | }; |
paul@62 | 69 | |
paul@62 | 70 | #endif /* __cplusplus */ |
paul@62 | 71 | |
paul@62 | 72 | |
paul@62 | 73 | |
paul@62 | 74 | /* C language interface. */ |
paul@62 | 75 | |
paul@62 | 76 | EXTERN_C_BEGIN |
paul@62 | 77 | |
paul@62 | 78 | void *jz4780_hdmi_init(l4_addr_t start, l4_addr_t end, l4_cap_idx_t irq); |
paul@62 | 79 | |
paul@62 | 80 | void jz4780_hdmi_get_version(void *hdmi, uint8_t *major, uint16_t *minor); |
paul@62 | 81 | |
paul@62 | 82 | int jz4780_hdmi_i2c_read(void *hdmi, uint8_t *buf, unsigned int length); |
paul@62 | 83 | |
paul@62 | 84 | void jz4780_hdmi_i2c_set_address(void *hdmi, uint8_t address); |
paul@62 | 85 | |
paul@62 | 86 | void jz4780_hdmi_i2c_set_segment(void *hdmi, uint8_t segment); |
paul@62 | 87 | |
paul@62 | 88 | void jz4780_hdmi_i2c_set_register(void *hdmi, uint8_t device_register); |
paul@62 | 89 | |
paul@62 | 90 | EXTERN_C_END |