1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2016 Google, Inc 4 * 5 * From coreboot broadwell support 6 */ 7 8 #include <common.h> 9 #include <dm.h> 10 #include <pch.h> 11 #include <asm/intel_regs.h> 12 #include <asm/io.h> 13 #include <asm/lpc_common.h> 14 #include <asm/arch/pch.h> 15 #include <asm/arch/spi.h> 16 17 static void set_spi_speed(void) 18 { 19 u32 fdod; 20 u8 ssfc; 21 22 /* Observe SPI Descriptor Component Section 0 */ 23 writel(0x1000, SPI_REG(SPIBAR_FDOC)); 24 25 /* Extract the Write/Erase SPI Frequency from descriptor */ 26 fdod = readl(SPI_REG(SPIBAR_FDOD)); 27 fdod >>= 24; 28 fdod &= 7; 29 30 /* Set Software Sequence frequency to match */ 31 ssfc = readb(SPI_REG(SPIBAR_SSFC + 2)); 32 ssfc &= ~7; 33 ssfc |= fdod; 34 writeb(ssfc, SPI_REG(SPIBAR_SSFC + 2)); 35 } 36 37 static int broadwell_lpc_early_init(struct udevice *dev) 38 { 39 set_spi_speed(); 40 41 return 0; 42 } 43 44 static int lpc_init_extra(struct udevice *dev) 45 { 46 return 0; 47 } 48 49 static int broadwell_lpc_probe(struct udevice *dev) 50 { 51 int ret; 52 53 if (!(gd->flags & GD_FLG_RELOC)) { 54 ret = lpc_common_early_init(dev); 55 if (ret) { 56 debug("%s: lpc_early_init() failed\n", __func__); 57 return ret; 58 } 59 60 return broadwell_lpc_early_init(dev); 61 } 62 63 return lpc_init_extra(dev); 64 } 65 66 static const struct udevice_id broadwell_lpc_ids[] = { 67 { .compatible = "intel,broadwell-lpc" }, 68 { } 69 }; 70 71 U_BOOT_DRIVER(broadwell_lpc_drv) = { 72 .name = "lpc", 73 .id = UCLASS_LPC, 74 .of_match = broadwell_lpc_ids, 75 .probe = broadwell_lpc_probe, 76 }; 77