superio/smsc/sio1036: Fix hardcoded TTY0 base addr and .c include
Compile romstage component as link-time symbols. Pass CONFIG_TTY0_BASE as argument instead of hard coding and playing funny business with the pre-processor. Fix board to match. Change-Id: If6d0d5389bd4e7765bb6056cf488c94fd45915c2 Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-on: http://review.coreboot.org/6463 Tested-by: build bot (Jenkins) Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
		@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 | 
				
			|||||||
	select NORTHBRIDGE_AMD_AGESA_FAMILY15
 | 
						select NORTHBRIDGE_AMD_AGESA_FAMILY15
 | 
				
			||||||
	select NORTHBRIDGE_AMD_CIMX_RD890
 | 
						select NORTHBRIDGE_AMD_CIMX_RD890
 | 
				
			||||||
	select SOUTHBRIDGE_AMD_CIMX_SB700
 | 
						select SOUTHBRIDGE_AMD_CIMX_SB700
 | 
				
			||||||
 | 
						select SUPERIO_SMSC_SIO1036
 | 
				
			||||||
	select SUPERIO_SMSC_SCH4037
 | 
						select SUPERIO_SMSC_SCH4037
 | 
				
			||||||
	select BOARD_ROMSIZE_KB_2048
 | 
						select BOARD_ROMSIZE_KB_2048
 | 
				
			||||||
	select HAVE_OPTION_TABLE
 | 
						select HAVE_OPTION_TABLE
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@ chip northbridge/amd/agesa/family15/root_complex
 | 
				
			|||||||
							irq 0x70 = 1	# PS/2 keyboard interrupt
 | 
												irq 0x70 = 1	# PS/2 keyboard interrupt
 | 
				
			||||||
							irq 0x72 = 12	# PS/2 mouse interrupt
 | 
												irq 0x72 = 12	# PS/2 mouse interrupt
 | 
				
			||||||
						end
 | 
											end
 | 
				
			||||||
					end #SIO SMSC307
 | 
										end #SIO SMSC SCH4037
 | 
				
			||||||
				end #LPC
 | 
									end #LPC
 | 
				
			||||||
				device pci 14.4 on end # PCI bridge, 0x4384
 | 
									device pci 14.4 on end # PCI bridge, 0x4384
 | 
				
			||||||
					device pci 14.5 on end # USB 3
 | 
										device pci 14.5 on end # USB 3
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,12 +33,12 @@
 | 
				
			|||||||
#include <northbridge/amd/agesa/agesawrapper_call.h>
 | 
					#include <northbridge/amd/agesa/agesawrapper_call.h>
 | 
				
			||||||
#include "cpu/x86/bist.h"
 | 
					#include "cpu/x86/bist.h"
 | 
				
			||||||
#include "superio/smsc/sch4037/sch4037_early_init.c"
 | 
					#include "superio/smsc/sch4037/sch4037_early_init.c"
 | 
				
			||||||
#include "superio/smsc/sio1036/sio1036_early_init.c"
 | 
					#include <superio/smsc/sio1036/sio1036.h>
 | 
				
			||||||
#include "cpu/x86/lapic.h"
 | 
					#include "cpu/x86/lapic.h"
 | 
				
			||||||
#include "nb_cimx.h"
 | 
					#include "nb_cimx.h"
 | 
				
			||||||
#include <sb_cimx.h>
 | 
					#include <sb_cimx.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
 | 
					#define SERIAL_DEV PNP_DEV(0x4e, SIO1036_SP1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
 | 
					void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -50,11 +50,7 @@ void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		sch4037_early_init(0x2e);
 | 
							sch4037_early_init(0x2e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Detect SMSC SIO1036 LPC Debug Card status */
 | 
							sio1036_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
 | 
				
			||||||
		if (detect_sio1036_chip(0x4E)) {
 | 
					 | 
				
			||||||
			/* Found SMSC SIO1036 LPC Debug Card */
 | 
					 | 
				
			||||||
			sio1036_early_init(0x4E);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		post_code(0x31);
 | 
							post_code(0x31);
 | 
				
			||||||
		console_init();
 | 
							console_init();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,4 +17,5 @@
 | 
				
			|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 | 
					# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					romstage-$(CONFIG_SUPERIO_SMSC_SIO1036) += sio1036_early_init.c
 | 
				
			||||||
ramstage-$(CONFIG_SUPERIO_SMSC_SIO1036) += superio.c
 | 
					ramstage-$(CONFIG_SUPERIO_SMSC_SIO1036) += superio.c
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,4 +26,9 @@
 | 
				
			|||||||
#define LPT_POWER_DOWN		(1 << 2)
 | 
					#define LPT_POWER_DOWN		(1 << 2)
 | 
				
			||||||
#define IR_OUPUT_MUX		(1 << 6)
 | 
					#define IR_OUPUT_MUX		(1 << 6)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <arch/io.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void sio1036_enable_serial(device_t dev, u16 iobase);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* SUPERIO_SMSC_1306_H */
 | 
					#endif /* SUPERIO_SMSC_1306_H */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,50 +20,49 @@
 | 
				
			|||||||
/* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
 | 
					/* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <arch/io.h>
 | 
					#include <arch/io.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "sio1036.h"
 | 
					#include "sio1036.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef CONFIG_TTYS0_BASE
 | 
					 | 
				
			||||||
#define CONFIG_TTYS0_BASE 0x3F8
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
static inline void sio1036_enter_conf_state(device_t dev)
 | 
					static inline void sio1036_enter_conf_state(device_t dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned port = dev>>8;
 | 
						unsigned port = dev >> 8;
 | 
				
			||||||
	outb(0x55, port);
 | 
						outb(0x55, port);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void sio1036_exit_conf_state(device_t dev)
 | 
					static inline void sio1036_exit_conf_state(device_t dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned port = dev>>8;
 | 
						unsigned port = dev >> 8;
 | 
				
			||||||
	outb(0xaa, port);
 | 
						outb(0xaa, port);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Detect SMSC SIO1036 LPC Debug Card status */
 | 
				
			||||||
static u8 detect_sio1036_chip(unsigned port)
 | 
					static u8 detect_sio1036_chip(unsigned port)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	device_t dev;
 | 
						device_t dev = PNP_DEV(port, SIO1036_SP1);
 | 
				
			||||||
	dev = PNP_DEV (port, SIO1036_SP1);
 | 
					 | 
				
			||||||
	unsigned data;
 | 
						unsigned data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sio1036_enter_conf_state (dev);
 | 
						sio1036_enter_conf_state (dev);
 | 
				
			||||||
	data = pnp_read_config (dev, 0x0D);
 | 
						data = pnp_read_config (dev, 0x0D);
 | 
				
			||||||
	sio1036_exit_conf_state(dev);
 | 
						sio1036_exit_conf_state(dev);
 | 
				
			||||||
	/* detect smsc sio1036 chip */
 | 
					
 | 
				
			||||||
 | 
						/* Detect SMSC SIO1036 chip */
 | 
				
			||||||
	if (data == 0x82) {
 | 
						if (data == 0x82) {
 | 
				
			||||||
		/* Found SMSC SIO1036 chip */
 | 
							/* Found SMSC SIO1036 chip */
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		return -1;
 | 
							return 1;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void sio1036_early_init(unsigned port)
 | 
					void sio1036_enable_serial(device_t dev, u16 iobase)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	device_t dev;
 | 
						unsigned port = dev >> 8;
 | 
				
			||||||
	dev = PNP_DEV (port, SIO1036_SP1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (detect_sio1036_chip(port) != 0) {
 | 
						if (detect_sio1036_chip(port) != 0)
 | 
				
			||||||
		/* Not found SMSC SIO1036 */
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
					
 | 
				
			||||||
	sio1036_enter_conf_state (dev);
 | 
						sio1036_enter_conf_state (dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Enable SMSC UART 0 */
 | 
						/* Enable SMSC UART 0 */
 | 
				
			||||||
@@ -91,7 +90,7 @@ static inline void sio1036_early_init(unsigned port)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* Enable SMSC UART 0 */
 | 
						/* Enable SMSC UART 0 */
 | 
				
			||||||
	/*Set base io address */
 | 
						/*Set base io address */
 | 
				
			||||||
	pnp_write_config (dev, 0x25, (u8)((u16)CONFIG_TTYS0_BASE >> 2));
 | 
						pnp_write_config (dev, 0x25, (u8)(iobase >> 2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Set UART IRQ onto 0x04 */
 | 
						/* Set UART IRQ onto 0x04 */
 | 
				
			||||||
	pnp_write_config (dev, 0x28, 0x04);
 | 
						pnp_write_config (dev, 0x28, 0x04);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user