1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /* Pre-RAM driver for SMSC LPC47N217 Super I/O chip. */
6 #include <device/pnp_ops.h>
10 static void pnp_enter_conf_state(pnp_devfn_t dev
)
16 static void pnp_exit_conf_state(pnp_devfn_t dev
)
23 * Program the base I/O port for the specified logical device.
25 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
26 * @param iobase Base I/O port for the logical device.
28 static void lpc47n217_pnp_set_iobase(pnp_devfn_t dev
, u16 iobase
)
30 /* LPC47N217 requires base ports to be a multiple of 4. */
31 ASSERT(!(iobase
& 0x3));
35 pnp_write_config(dev
, 0x23, (iobase
>> 2) & 0xff);
38 pnp_write_config(dev
, 0x24, (iobase
>> 2) & 0xff);
41 pnp_write_config(dev
, 0x25, (iobase
>> 2) & 0xff);
49 * Enable or disable the specified logical device.
51 * Technically, a full disable requires setting the device's base I/O port
52 * below 0x100. We don't do that here, because we don't have access to a data
53 * structure that specifies what the 'real' base port is (when asked to enable
54 * the device). Also the function is used only to disable the device while its
55 * true base port is programmed (see lpc47n217_enable_serial() below).
57 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
58 * @param enable 0 to disable, anything else to enable.
60 static void lpc47n217_pnp_set_enable(pnp_devfn_t dev
, int enable
)
62 u8 power_register
= 0, power_mask
= 0, current_power
, new_power
;
66 power_register
= 0x01;
70 power_register
= 0x02;
74 power_register
= 0x02;
81 current_power
= pnp_read_config(dev
, power_register
);
82 new_power
= current_power
& ~power_mask
; /* Disable by default. */
84 new_power
|= power_mask
; /* Enable. */
85 pnp_write_config(dev
, power_register
, new_power
);
89 * Configure the base I/O port of the specified serial device and enable the
92 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
93 * @param iobase Processor I/O port address to assign to this serial device.
95 void lpc47n217_enable_serial(pnp_devfn_t dev
, u16 iobase
)
98 * NOTE: Cannot use pnp_set_XXX() here because they assume chip
99 * support for logical devices, which the LPC47N217 doesn't have.
101 pnp_enter_conf_state(dev
);
102 lpc47n217_pnp_set_enable(dev
, 0);
103 lpc47n217_pnp_set_iobase(dev
, iobase
);
104 lpc47n217_pnp_set_enable(dev
, 1);
105 pnp_exit_conf_state(dev
);