common: Drop init.h from common header
[platform/kernel/u-boot.git] / arch / x86 / cpu / broadwell / cpu_full.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2016 Google, Inc
4  *
5  * Based on code from coreboot src/soc/intel/broadwell/cpu.c
6  */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <cpu.h>
11 #include <init.h>
12 #include <asm/cpu.h>
13 #include <asm/cpu_x86.h>
14 #include <asm/cpu_common.h>
15 #include <asm/intel_regs.h>
16 #include <asm/msr.h>
17 #include <asm/post.h>
18 #include <asm/turbo.h>
19 #include <asm/arch/cpu.h>
20 #include <asm/arch/pch.h>
21 #include <asm/arch/rcb.h>
22
23 struct cpu_broadwell_priv {
24         bool ht_disabled;
25 };
26
27 /* Convert time in seconds to POWER_LIMIT_1_TIME MSR value */
28 static const u8 power_limit_time_sec_to_msr[] = {
29         [0]   = 0x00,
30         [1]   = 0x0a,
31         [2]   = 0x0b,
32         [3]   = 0x4b,
33         [4]   = 0x0c,
34         [5]   = 0x2c,
35         [6]   = 0x4c,
36         [7]   = 0x6c,
37         [8]   = 0x0d,
38         [10]  = 0x2d,
39         [12]  = 0x4d,
40         [14]  = 0x6d,
41         [16]  = 0x0e,
42         [20]  = 0x2e,
43         [24]  = 0x4e,
44         [28]  = 0x6e,
45         [32]  = 0x0f,
46         [40]  = 0x2f,
47         [48]  = 0x4f,
48         [56]  = 0x6f,
49         [64]  = 0x10,
50         [80]  = 0x30,
51         [96]  = 0x50,
52         [112] = 0x70,
53         [128] = 0x11,
54 };
55
56 /* Convert POWER_LIMIT_1_TIME MSR value to seconds */
57 static const u8 power_limit_time_msr_to_sec[] = {
58         [0x00] = 0,
59         [0x0a] = 1,
60         [0x0b] = 2,
61         [0x4b] = 3,
62         [0x0c] = 4,
63         [0x2c] = 5,
64         [0x4c] = 6,
65         [0x6c] = 7,
66         [0x0d] = 8,
67         [0x2d] = 10,
68         [0x4d] = 12,
69         [0x6d] = 14,
70         [0x0e] = 16,
71         [0x2e] = 20,
72         [0x4e] = 24,
73         [0x6e] = 28,
74         [0x0f] = 32,
75         [0x2f] = 40,
76         [0x4f] = 48,
77         [0x6f] = 56,
78         [0x10] = 64,
79         [0x30] = 80,
80         [0x50] = 96,
81         [0x70] = 112,
82         [0x11] = 128,
83 };
84
85 #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
86 int arch_cpu_init(void)
87 {
88         return 0;
89 }
90 #endif
91
92 /*
93  * The core 100MHz BLCK is disabled in deeper c-states. One needs to calibrate
94  * the 100MHz BCLCK against the 24MHz BLCK to restore the clocks properly
95  * when a core is woken up
96  */
97 static int pcode_ready(void)
98 {
99         int wait_count;
100         const int delay_step = 10;
101
102         wait_count = 0;
103         do {
104                 if (!(readl(MCHBAR_REG(BIOS_MAILBOX_INTERFACE)) &
105                                 MAILBOX_RUN_BUSY))
106                         return 0;
107                 wait_count += delay_step;
108                 udelay(delay_step);
109         } while (wait_count < 1000);
110
111         return -ETIMEDOUT;
112 }
113
114 static u32 pcode_mailbox_read(u32 command)
115 {
116         int ret;
117
118         ret = pcode_ready();
119         if (ret) {
120                 debug("PCODE: mailbox timeout on wait ready\n");
121                 return ret;
122         }
123
124         /* Send command and start transaction */
125         writel(command | MAILBOX_RUN_BUSY, MCHBAR_REG(BIOS_MAILBOX_INTERFACE));
126
127         ret = pcode_ready();
128         if (ret) {
129                 debug("PCODE: mailbox timeout on completion\n");
130                 return ret;
131         }
132
133         /* Read mailbox */
134         return readl(MCHBAR_REG(BIOS_MAILBOX_DATA));
135 }
136
137 static int pcode_mailbox_write(u32 command, u32 data)
138 {
139         int ret;
140
141         ret = pcode_ready();
142         if (ret) {
143                 debug("PCODE: mailbox timeout on wait ready\n");
144                 return ret;
145         }
146
147         writel(data, MCHBAR_REG(BIOS_MAILBOX_DATA));
148
149         /* Send command and start transaction */
150         writel(command | MAILBOX_RUN_BUSY, MCHBAR_REG(BIOS_MAILBOX_INTERFACE));
151
152         ret = pcode_ready();
153         if (ret) {
154                 debug("PCODE: mailbox timeout on completion\n");
155                 return ret;
156         }
157
158         return 0;
159 }
160
161 /* @dev is the CPU device */
162 static void initialize_vr_config(struct udevice *dev)
163 {
164         int ramp, min_vid;
165         msr_t msr;
166
167         debug("Initializing VR config\n");
168
169         /* Configure VR_CURRENT_CONFIG */
170         msr = msr_read(MSR_VR_CURRENT_CONFIG);
171         /*
172          * Preserve bits 63 and 62. Bit 62 is PSI4 enable, but it is only valid
173          * on ULT systems
174          */
175         msr.hi &= 0xc0000000;
176         msr.hi |= (0x01 << (52 - 32)); /* PSI3 threshold -  1A */
177         msr.hi |= (0x05 << (42 - 32)); /* PSI2 threshold -  5A */
178         msr.hi |= (0x14 << (32 - 32)); /* PSI1 threshold - 20A */
179         msr.hi |= (1 <<  (62 - 32)); /* Enable PSI4 */
180         /* Leave the max instantaneous current limit (12:0) to default */
181         msr_write(MSR_VR_CURRENT_CONFIG, msr);
182
183         /* Configure VR_MISC_CONFIG MSR */
184         msr = msr_read(MSR_VR_MISC_CONFIG);
185         /* Set the IOUT_SLOPE scalar applied to dIout in U10.1.9 format */
186         msr.hi &= ~(0x3ff << (40 - 32));
187         msr.hi |= (0x200 << (40 - 32)); /* 1.0 */
188         /* Set IOUT_OFFSET to 0 */
189         msr.hi &= ~0xff;
190         /* Set entry ramp rate to slow */
191         msr.hi &= ~(1 << (51 - 32));
192         /* Enable decay mode on C-state entry */
193         msr.hi |= (1 << (52 - 32));
194         /* Set the slow ramp rate */
195         msr.hi &= ~(0x3 << (53 - 32));
196         /* Configure the C-state exit ramp rate */
197         ramp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
198                               "intel,slow-ramp", -1);
199         if (ramp != -1) {
200                 /* Configured slow ramp rate */
201                 msr.hi |= ((ramp & 0x3) << (53 - 32));
202                 /* Set exit ramp rate to slow */
203                 msr.hi &= ~(1 << (50 - 32));
204         } else {
205                 /* Fast ramp rate / 4 */
206                 msr.hi |= (0x01 << (53 - 32));
207                 /* Set exit ramp rate to fast */
208                 msr.hi |= (1 << (50 - 32));
209         }
210         /* Set MIN_VID (31:24) to allow CPU to have full control */
211         msr.lo &= ~0xff000000;
212         min_vid = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
213                                  "intel,min-vid", 0);
214         msr.lo |= (min_vid & 0xff) << 24;
215         msr_write(MSR_VR_MISC_CONFIG, msr);
216
217         /*  Configure VR_MISC_CONFIG2 MSR */
218         msr = msr_read(MSR_VR_MISC_CONFIG2);
219         msr.lo &= ~0xffff;
220         /*
221          * Allow CPU to control minimum voltage completely (15:8) and
222          * set the fast ramp voltage in 10mV steps
223          */
224         if (cpu_get_family_model() == BROADWELL_FAMILY_ULT)
225                 msr.lo |= 0x006a; /* 1.56V */
226         else
227                 msr.lo |= 0x006f; /* 1.60V */
228         msr_write(MSR_VR_MISC_CONFIG2, msr);
229
230         /* Set C9/C10 VCC Min */
231         pcode_mailbox_write(MAILBOX_BIOS_CMD_WRITE_C9C10_VOLTAGE, 0x1f1f);
232 }
233
234 static int calibrate_24mhz_bclk(void)
235 {
236         int err_code;
237         int ret;
238
239         ret = pcode_ready();
240         if (ret)
241                 return ret;
242
243         /* A non-zero value initiates the PCODE calibration */
244         writel(~0, MCHBAR_REG(BIOS_MAILBOX_DATA));
245         writel(MAILBOX_RUN_BUSY | MAILBOX_BIOS_CMD_FSM_MEASURE_INTVL,
246                MCHBAR_REG(BIOS_MAILBOX_INTERFACE));
247
248         ret = pcode_ready();
249         if (ret)
250                 return ret;
251
252         err_code = readl(MCHBAR_REG(BIOS_MAILBOX_INTERFACE)) & 0xff;
253
254         debug("PCODE: 24MHz BLCK calibration response: %d\n", err_code);
255
256         /* Read the calibrated value */
257         writel(MAILBOX_RUN_BUSY | MAILBOX_BIOS_CMD_READ_CALIBRATION,
258                MCHBAR_REG(BIOS_MAILBOX_INTERFACE));
259
260         ret = pcode_ready();
261         if (ret)
262                 return ret;
263
264         debug("PCODE: 24MHz BLCK calibration value: 0x%08x\n",
265               readl(MCHBAR_REG(BIOS_MAILBOX_DATA)));
266
267         return 0;
268 }
269
270 static void configure_pch_power_sharing(void)
271 {
272         u32 pch_power, pch_power_ext, pmsync, pmsync2;
273         int i;
274
275         /* Read PCH Power levels from PCODE */
276         pch_power = pcode_mailbox_read(MAILBOX_BIOS_CMD_READ_PCH_POWER);
277         pch_power_ext = pcode_mailbox_read(MAILBOX_BIOS_CMD_READ_PCH_POWER_EXT);
278
279         debug("PCH Power: PCODE Levels 0x%08x 0x%08x\n", pch_power,
280               pch_power_ext);
281
282         pmsync = readl(RCB_REG(PMSYNC_CONFIG));
283         pmsync2 = readl(RCB_REG(PMSYNC_CONFIG2));
284
285         /*
286          * Program PMSYNC_TPR_CONFIG PCH power limit values
287          *  pmsync[0:4]   = mailbox[0:5]
288          *  pmsync[8:12]  = mailbox[6:11]
289          *  pmsync[16:20] = mailbox[12:17]
290          */
291         for (i = 0; i < 3; i++) {
292                 u32 level = pch_power & 0x3f;
293
294                 pch_power >>= 6;
295                 pmsync &= ~(0x1f << (i * 8));
296                 pmsync |= (level & 0x1f) << (i * 8);
297         }
298         writel(pmsync, RCB_REG(PMSYNC_CONFIG));
299
300         /*
301          * Program PMSYNC_TPR_CONFIG2 Extended PCH power limit values
302          *  pmsync2[0:4]   = mailbox[23:18]
303          *  pmsync2[8:12]  = mailbox_ext[6:11]
304          *  pmsync2[16:20] = mailbox_ext[12:17]
305          *  pmsync2[24:28] = mailbox_ext[18:22]
306          */
307         pmsync2 &= ~0x1f;
308         pmsync2 |= pch_power & 0x1f;
309
310         for (i = 1; i < 4; i++) {
311                 u32 level = pch_power_ext & 0x3f;
312
313                 pch_power_ext >>= 6;
314                 pmsync2 &= ~(0x1f << (i * 8));
315                 pmsync2 |= (level & 0x1f) << (i * 8);
316         }
317         writel(pmsync2, RCB_REG(PMSYNC_CONFIG2));
318 }
319
320 static int bsp_init_before_ap_bringup(struct udevice *dev)
321 {
322         int ret;
323
324         initialize_vr_config(dev);
325         ret = calibrate_24mhz_bclk();
326         if (ret)
327                 return ret;
328         configure_pch_power_sharing();
329
330         return 0;
331 }
332
333 static void set_max_ratio(void)
334 {
335         msr_t msr, perf_ctl;
336
337         perf_ctl.hi = 0;
338
339         /* Check for configurable TDP option */
340         if (turbo_get_state() == TURBO_ENABLED) {
341                 msr = msr_read(MSR_TURBO_RATIO_LIMIT);
342                 perf_ctl.lo = (msr.lo & 0xff) << 8;
343         } else if (cpu_config_tdp_levels()) {
344                 /* Set to nominal TDP ratio */
345                 msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
346                 perf_ctl.lo = (msr.lo & 0xff) << 8;
347         } else {
348                 /* Platform Info bits 15:8 give max ratio */
349                 msr = msr_read(MSR_PLATFORM_INFO);
350                 perf_ctl.lo = msr.lo & 0xff00;
351         }
352         msr_write(MSR_IA32_PERF_CTL, perf_ctl);
353
354         debug("cpu: frequency set to %d\n",
355               ((perf_ctl.lo >> 8) & 0xff) * INTEL_BCLK_MHZ);
356 }
357
358 int broadwell_init(struct udevice *dev)
359 {
360         struct cpu_broadwell_priv *priv = dev_get_priv(dev);
361         int num_threads;
362         int num_cores;
363         msr_t msr;
364         int ret;
365
366         msr = msr_read(CORE_THREAD_COUNT_MSR);
367         num_threads = (msr.lo >> 0) & 0xffff;
368         num_cores = (msr.lo >> 16) & 0xffff;
369         debug("CPU has %u cores, %u threads enabled\n", num_cores,
370               num_threads);
371
372         priv->ht_disabled = num_threads == num_cores;
373
374         ret = bsp_init_before_ap_bringup(dev);
375         if (ret)
376                 return ret;
377
378         set_max_ratio();
379
380         return ret;
381 }
382
383 static void configure_mca(void)
384 {
385         msr_t msr;
386         const unsigned int mcg_cap_msr = 0x179;
387         int i;
388         int num_banks;
389
390         msr = msr_read(mcg_cap_msr);
391         num_banks = msr.lo & 0xff;
392         msr.lo = 0;
393         msr.hi = 0;
394         /*
395          * TODO(adurbin): This should only be done on a cold boot. Also, some
396          * of these banks are core vs package scope. For now every CPU clears
397          * every bank
398          */
399         for (i = 0; i < num_banks; i++)
400                 msr_write(MSR_IA32_MC0_STATUS + (i * 4), msr);
401 }
402
403 static void enable_lapic_tpr(void)
404 {
405         msr_t msr;
406
407         msr = msr_read(MSR_PIC_MSG_CONTROL);
408         msr.lo &= ~(1 << 10);   /* Enable APIC TPR updates */
409         msr_write(MSR_PIC_MSG_CONTROL, msr);
410 }
411
412 static void configure_c_states(void)
413 {
414         msr_t msr;
415
416         msr = msr_read(MSR_PMG_CST_CONFIG_CONTROL);
417         msr.lo |= (1 << 31);    /* Timed MWAIT Enable */
418         msr.lo |= (1 << 30);    /* Package c-state Undemotion Enable */
419         msr.lo |= (1 << 29);    /* Package c-state Demotion Enable */
420         msr.lo |= (1 << 28);    /* C1 Auto Undemotion Enable */
421         msr.lo |= (1 << 27);    /* C3 Auto Undemotion Enable */
422         msr.lo |= (1 << 26);    /* C1 Auto Demotion Enable */
423         msr.lo |= (1 << 25);    /* C3 Auto Demotion Enable */
424         msr.lo &= ~(1 << 10);   /* Disable IO MWAIT redirection */
425         /* The deepest package c-state defaults to factory-configured value */
426         msr_write(MSR_PMG_CST_CONFIG_CONTROL, msr);
427
428         msr = msr_read(MSR_MISC_PWR_MGMT);
429         msr.lo &= ~(1 << 0);    /* Enable P-state HW_ALL coordination */
430         msr_write(MSR_MISC_PWR_MGMT, msr);
431
432         msr = msr_read(MSR_POWER_CTL);
433         msr.lo |= (1 << 18);    /* Enable Energy Perf Bias MSR 0x1b0 */
434         msr.lo |= (1 << 1);     /* C1E Enable */
435         msr.lo |= (1 << 0);     /* Bi-directional PROCHOT# */
436         msr_write(MSR_POWER_CTL, msr);
437
438         /* C-state Interrupt Response Latency Control 0 - package C3 latency */
439         msr.hi = 0;
440         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_0_LIMIT;
441         msr_write(MSR_C_STATE_LATENCY_CONTROL_0, msr);
442
443         /* C-state Interrupt Response Latency Control 1 */
444         msr.hi = 0;
445         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_1_LIMIT;
446         msr_write(MSR_C_STATE_LATENCY_CONTROL_1, msr);
447
448         /* C-state Interrupt Response Latency Control 2 - package C6/C7 short */
449         msr.hi = 0;
450         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_2_LIMIT;
451         msr_write(MSR_C_STATE_LATENCY_CONTROL_2, msr);
452
453         /* C-state Interrupt Response Latency Control 3 - package C8 */
454         msr.hi = 0;
455         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_3_LIMIT;
456         msr_write(MSR_C_STATE_LATENCY_CONTROL_3, msr);
457
458         /* C-state Interrupt Response Latency Control 4 - package C9 */
459         msr.hi = 0;
460         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_4_LIMIT;
461         msr_write(MSR_C_STATE_LATENCY_CONTROL_4, msr);
462
463         /* C-state Interrupt Response Latency Control 5 - package C10 */
464         msr.hi = 0;
465         msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_5_LIMIT;
466         msr_write(MSR_C_STATE_LATENCY_CONTROL_5, msr);
467 }
468
469 static void configure_misc(void)
470 {
471         msr_t msr;
472
473         msr = msr_read(MSR_IA32_MISC_ENABLE);
474         msr.lo |= MISC_ENABLE_FAST_STRING;
475         msr.lo |= MISC_ENABLE_TM1;
476         msr.lo |= MISC_ENABLE_ENHANCED_SPEEDSTEP;
477         msr_write(MSR_IA32_MISC_ENABLE, msr);
478
479         /* Disable thermal interrupts */
480         msr.lo = 0;
481         msr.hi = 0;
482         msr_write(MSR_IA32_THERM_INTERRUPT, msr);
483
484         /* Enable package critical interrupt only */
485         msr.lo = 1 << 4;
486         msr.hi = 0;
487         msr_write(MSR_IA32_PACKAGE_THERM_INTERRUPT, msr);
488 }
489
490 static void configure_dca_cap(void)
491 {
492         struct cpuid_result cpuid_regs;
493         msr_t msr;
494
495         /* Check feature flag in CPUID.(EAX=1):ECX[18]==1 */
496         cpuid_regs = cpuid(1);
497         if (cpuid_regs.ecx & (1 << 18)) {
498                 msr = msr_read(MSR_IA32_PLATFORM_DCA_CAP);
499                 msr.lo |= 1;
500                 msr_write(MSR_IA32_PLATFORM_DCA_CAP, msr);
501         }
502 }
503
504 static void set_energy_perf_bias(u8 policy)
505 {
506         msr_t msr;
507         int ecx;
508
509         /* Determine if energy efficient policy is supported */
510         ecx = cpuid_ecx(0x6);
511         if (!(ecx & (1 << 3)))
512                 return;
513
514         /* Energy Policy is bits 3:0 */
515         msr = msr_read(MSR_IA32_ENERGY_PERFORMANCE_BIAS);
516         msr.lo &= ~0xf;
517         msr.lo |= policy & 0xf;
518         msr_write(MSR_IA32_ENERGY_PERFORMANCE_BIAS, msr);
519
520         debug("cpu: energy policy set to %u\n", policy);
521 }
522
523 /* All CPUs including BSP will run the following function */
524 static void cpu_core_init(struct udevice *dev)
525 {
526         /* Clear out pending MCEs */
527         configure_mca();
528
529         /* Enable the local cpu apics */
530         enable_lapic_tpr();
531
532         /* Configure C States */
533         configure_c_states();
534
535         /* Configure Enhanced SpeedStep and Thermal Sensors */
536         configure_misc();
537
538         /* Thermal throttle activation offset */
539         cpu_configure_thermal_target(dev);
540
541         /* Enable Direct Cache Access */
542         configure_dca_cap();
543
544         /* Set energy policy */
545         set_energy_perf_bias(ENERGY_POLICY_NORMAL);
546
547         /* Enable Turbo */
548         turbo_enable();
549 }
550
551 /*
552  * Configure processor power limits if possible
553  * This must be done AFTER set of BIOS_RESET_CPL
554  */
555 void cpu_set_power_limits(int power_limit_1_time)
556 {
557         msr_t msr;
558         msr_t limit;
559         uint power_unit;
560         uint tdp, min_power, max_power, max_time;
561         u8 power_limit_1_val;
562
563         msr = msr_read(MSR_PLATFORM_INFO);
564         if (power_limit_1_time > ARRAY_SIZE(power_limit_time_sec_to_msr))
565                 power_limit_1_time = 28;
566
567         if (!(msr.lo & PLATFORM_INFO_SET_TDP))
568                 return;
569
570         /* Get units */
571         msr = msr_read(MSR_PKG_POWER_SKU_UNIT);
572         power_unit = 2 << ((msr.lo & 0xf) - 1);
573
574         /* Get power defaults for this SKU */
575         msr = msr_read(MSR_PKG_POWER_SKU);
576         tdp = msr.lo & 0x7fff;
577         min_power = (msr.lo >> 16) & 0x7fff;
578         max_power = msr.hi & 0x7fff;
579         max_time = (msr.hi >> 16) & 0x7f;
580
581         debug("CPU TDP: %u Watts\n", tdp / power_unit);
582
583         if (power_limit_time_msr_to_sec[max_time] > power_limit_1_time)
584                 power_limit_1_time = power_limit_time_msr_to_sec[max_time];
585
586         if (min_power > 0 && tdp < min_power)
587                 tdp = min_power;
588
589         if (max_power > 0 && tdp > max_power)
590                 tdp = max_power;
591
592         power_limit_1_val = power_limit_time_sec_to_msr[power_limit_1_time];
593
594         /* Set long term power limit to TDP */
595         limit.lo = 0;
596         limit.lo |= tdp & PKG_POWER_LIMIT_MASK;
597         limit.lo |= PKG_POWER_LIMIT_EN;
598         limit.lo |= (power_limit_1_val & PKG_POWER_LIMIT_TIME_MASK) <<
599                 PKG_POWER_LIMIT_TIME_SHIFT;
600
601         /* Set short term power limit to 1.25 * TDP */
602         limit.hi = 0;
603         limit.hi |= ((tdp * 125) / 100) & PKG_POWER_LIMIT_MASK;
604         limit.hi |= PKG_POWER_LIMIT_EN;
605         /* Power limit 2 time is only programmable on server SKU */
606
607         msr_write(MSR_PKG_POWER_LIMIT, limit);
608
609         /* Set power limit values in MCHBAR as well */
610         writel(limit.lo, MCHBAR_REG(MCH_PKG_POWER_LIMIT_LO));
611         writel(limit.hi, MCHBAR_REG(MCH_PKG_POWER_LIMIT_HI));
612
613         /* Set DDR RAPL power limit by copying from MMIO to MSR */
614         msr.lo = readl(MCHBAR_REG(MCH_DDR_POWER_LIMIT_LO));
615         msr.hi = readl(MCHBAR_REG(MCH_DDR_POWER_LIMIT_HI));
616         msr_write(MSR_DDR_RAPL_LIMIT, msr);
617
618         /* Use nominal TDP values for CPUs with configurable TDP */
619         if (cpu_config_tdp_levels()) {
620                 msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
621                 limit.hi = 0;
622                 limit.lo = msr.lo & 0xff;
623                 msr_write(MSR_TURBO_ACTIVATION_RATIO, limit);
624         }
625 }
626
627 static int broadwell_get_info(struct udevice *dev, struct cpu_info *info)
628 {
629         return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
630 }
631
632 static int broadwell_get_count(struct udevice *dev)
633 {
634         return 4;
635 }
636
637 static int cpu_x86_broadwell_probe(struct udevice *dev)
638 {
639         if (dev->seq == 0) {
640                 cpu_core_init(dev);
641                 return broadwell_init(dev);
642         }
643
644         return 0;
645 }
646
647 static const struct cpu_ops cpu_x86_broadwell_ops = {
648         .get_desc       = cpu_x86_get_desc,
649         .get_info       = broadwell_get_info,
650         .get_count      = broadwell_get_count,
651         .get_vendor     = cpu_x86_get_vendor,
652 };
653
654 static const struct udevice_id cpu_x86_broadwell_ids[] = {
655         { .compatible = "intel,core-i3-gen5" },
656         { }
657 };
658
659 U_BOOT_DRIVER(cpu_x86_broadwell_drv) = {
660         .name           = "cpu_x86_broadwell",
661         .id             = UCLASS_CPU,
662         .of_match       = cpu_x86_broadwell_ids,
663         .bind           = cpu_x86_bind,
664         .probe          = cpu_x86_broadwell_probe,
665         .ops            = &cpu_x86_broadwell_ops,
666         .priv_auto_alloc_size   = sizeof(struct cpu_broadwell_priv),
667         .flags          = DM_FLAG_PRE_RELOC,
668 };