1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* Pre-RAM driver for SMSC LPC47N227 Super I/O chip. */
7 #include <device/pnp_ops.h>
11 void pnp_enter_conf_state(pnp_devfn_t dev
)
17 void pnp_exit_conf_state(pnp_devfn_t dev
)
24 * Program the base I/O port for the specified logical device.
26 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
27 * @param iobase Base I/O port for the logical device.
29 static void lpc47n227_pnp_set_iobase(pnp_devfn_t dev
, u16 iobase
)
31 /* LPC47N227 requires base ports to be a multiple of 4. */
32 /* it's not very useful to do an ASSERT here: if it trips,
33 * there's no console to report it.
34 ASSERT(!(iobase & 0x3));
39 pnp_write_config(dev
, 0x23, (iobase
>> 2) & 0xff);
42 pnp_write_config(dev
, 0x24, (iobase
>> 2) & 0xff);
45 pnp_write_config(dev
, 0x25, (iobase
>> 2) & 0xff);
53 * Enable or disable the specified logical device.
55 * Technically, a full disable requires setting the device's base I/O port
56 * below 0x100. We don't do that here, because we don't have access to a data
57 * structure that specifies what the 'real' base port is (when asked to enable
58 * the device). Also the function is used only to disable the device while its
59 * true base port is programmed (see lpc47n227_enable_serial() below).
61 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
62 * @param enable 0 to disable, anything else to enable.
64 static void lpc47n227_pnp_set_enable(pnp_devfn_t dev
, int enable
)
66 u8 power_register
= 0, power_mask
= 0, current_power
, new_power
;
70 power_register
= 0x01;
74 power_register
= 0x02;
78 power_register
= 0x02;
85 current_power
= pnp_read_config(dev
, power_register
);
86 new_power
= current_power
& ~power_mask
; /* Disable by default. */
88 new_power
|= power_mask
; /* Enable. */
89 pnp_write_config(dev
, power_register
, new_power
);
93 * Configure the base I/O port of the specified serial device and enable the
96 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
97 * @param iobase Processor I/O port address to assign to this serial device.
99 void lpc47n227_enable_serial(pnp_devfn_t dev
, u16 iobase
)
102 * NOTE: Cannot use pnp_set_XXX() here because they assume chip
103 * support for logical devices, which the LPC47N227 doesn't have.
105 pnp_enter_conf_state(dev
);
106 lpc47n227_pnp_set_enable(dev
, 0);
107 lpc47n227_pnp_set_iobase(dev
, iobase
);
108 lpc47n227_pnp_set_enable(dev
, 1);
109 pnp_exit_conf_state(dev
);