1 /* 2 * Copyright 2011-2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * François Revol, revol@free.fr 7 */ 8 9 10 #include <arch/arm/reg.h> 11 #include <arch/generic/debug_uart_8250.h> 12 #include <debug.h> 13 #include <omap3.h> 14 #include <new> 15 16 17 class ArchUART8250Omap : public DebugUART8250 { 18 public: 19 ArchUART8250Omap(addr_t base, int64 clock); 20 ~ArchUART8250Omap(); 21 void InitEarly(); 22 23 // ARM MMIO: on ARM the UART regs are aligned on 32bit 24 virtual void Out8(int reg, uint8 value); 25 virtual uint8 In8(int reg); 26 }; 27 28 29 ArchUART8250Omap::ArchUART8250Omap(addr_t base, int64 clock) 30 : 31 DebugUART8250(base, clock) 32 { 33 } 34 35 36 ArchUART8250Omap::~ArchUART8250Omap() 37 { 38 } 39 40 41 void 42 ArchUART8250Omap::InitEarly() 43 { 44 // Perform special hardware UART configuration 45 /* UART1 */ 46 RMWREG32(CM_FCLKEN1_CORE, 13, 1, 1); 47 RMWREG32(CM_ICLKEN1_CORE, 13, 1, 1); 48 49 /* UART2 */ 50 RMWREG32(CM_FCLKEN1_CORE, 14, 1, 1); 51 RMWREG32(CM_ICLKEN1_CORE, 14, 1, 1); 52 53 /* UART3 */ 54 RMWREG32(CM_FCLKEN_PER, 11, 1, 1); 55 RMWREG32(CM_ICLKEN_PER, 11, 1, 1); 56 } 57 58 59 void 60 ArchUART8250Omap::Out8(int reg, uint8 value) 61 { 62 *((uint8 *)Base() + reg * sizeof(uint32)) = value; 63 } 64 65 66 uint8 67 ArchUART8250Omap::In8(int reg) 68 { 69 return *((uint8 *)Base() + reg * sizeof(uint32)); 70 } 71 72 73 DebugUART8250 *arch_get_uart_8250_omap(addr_t base, int64 clock) 74 { 75 static char buffer[sizeof(ArchUART8250Omap)]; 76 ArchUART8250Omap *uart = new(buffer) ArchUART8250Omap(base, clock); 77 return uart; 78 } 79