<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear Zoran.<br>
<br>
<u>I was perectly understand the I2C algo</u>. It is very easy to
me.<br>
<br>
And I was know that I2C_DATA line is must need a mode
change(INPUT/OUTPUT) for bidirectional communication.<br>
<br>
<b>At present, I2C is not important to me.</b><br>
<br>
I want to say. that my purpose is just control GPIO pins.<br>
<br>
<br>
My problem is...<br>
<br>
Suppose this sistuation.<br>
<br>
Initial status of gpio<br>
<br>
<table border="1" cellpadding="2" cellspacing="2" width="70%">
<tbody>
<tr>
<td valign="top">pin<br>
</td>
<td valign="top">SC_IO_SEL<br>
</td>
<td valign="top">SC_GP_LVL<br>
</td>
</tr>
<tr>
<td valign="top">GPIO_11(reset of some ic)<br>
</td>
<td valign="top">output<br>
</td>
<td valign="top">HIGH<br>
</td>
</tr>
<tr>
<td valign="top">GPIO_12(LED1)<br>
</td>
<td valign="top">output<br>
</td>
<td valign="top">LOW<br>
</td>
</tr>
<tr>
<td valign="top">GPIO_13(detect pin)<br>
</td>
<td valign="top">input<br>
</td>
<td valign="top">HIGH<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
After power-on. suppose, must need turn on the GPIO_12(LED1).<br>
It is easy.<br>
<br>
void led_control(u32 pin_num)<br>
{<br>
u32 current_status = inl(gbase + SC_GP_LVL);<br>
current_status = setbit(current_status, pin_num);<br>
}<br>
<br>
<br>
<b>But, My case is can't read status of outputmode pins.</b><br>
<font color="#cc0000"> Can read</font> the status of <b>inputmode
pins</b>. <br>
But<font color="#cc0000"> Can't read</font> the status of <b>outputmode
pins.</b><br>
current status is very important information for bit
operation(set/clear).<br>
<br>
GPIO_11 is output mode => can't read this status.<br>
GPIO_12 is output mode => can't read this status.<br>
GPIO_13 is input mode => can read this status.<br>
<br>
If I try to control without knowing the current state, <b>must
becomes problem.</b><br>
<br>
So, I try to find the solution that "How to read the status of
outputmode gpio pins"<br>
<br>
<br>
Another platform is can get a status of pin. use by "register of
IO direction" and "register of IO Level".<br>
<br>
If I use the AND operation, can get a status of output mode pins.<br>
<br>
<br>
Please any idea?<br>
<br>
Thank you. <br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
2016-07-20 오후 3:56에 Zoran Stojsavljevic 이(가) 쓴 글:<br>
</div>
<blockquote
cite="mid:CAGAf8Lyu-d9q2JQjWWXdGaLBYMbcob3Q59_rQta+EB+gwcvexg@mail.gmail.com"
type="cite">
<div dir="ltr">Hello Kim,
<div><br>
</div>
<div>Kim, listen to me/read me now very carefully. Please. :-)</div>
<div><br>
</div>
<div>For the standard I2C interface, you have only two serial
lines: I2C_CLK and I2C_DATA. Your C2000 is master, so it will
ALWAYS provide I2C_CLK as OUT. With I2C_DATA things are a bit
more complicated. It is IN/OUT line, and once you output on
it, you MUST turn it around.</div>
<div><br>
</div>
<div>I'll provide to you an adequate example. Let us assume <span
style="font-size:12.8px">SC_USE_SEL has two dedicated IO_14
as I2C_CLK, and IO_13 as I2C_DATA.</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">For the I2C_CLK, it is
always output. For I2C_DATA, it is bidirectional.</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">So, when you supply slave
I2C address on the bus, the following is true:</span></div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_USE_SEL
: 6000</span><br>
</div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_IO_SEL
: 0 (all pins as OUT direction)</span><br
style="color:rgb(80,0,80);font-size:12.8px">
<span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_GP_LVL
: bit banging on pins 13, 14</span><br>
</div>
<div><span style="color:rgb(80,0,80);font-size:12.8px"><br>
</span></div>
<div><font color="#500050"><span style="font-size:12.8px">Now,
you need to turn around your data bus, to be IN. Here is
the situation:</span></font></div>
<div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_USE_SEL
: 6000</span><br>
</div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_IO_SEL
: 2000 (pin 13 is now defined as IN direction!)</span><br
style="color:rgb(80,0,80);font-size:12.8px">
<span style="color:rgb(80,0,80);font-size:12.8px">GPIO_SC_GP_LVL
: answer coming on pin 13, you have to sample it correctly
in time READing this register (only bit 13 is valid) and
looking into bit 13 value).</span><br>
</div>
</div>
<div><span style="color:rgb(80,0,80);font-size:12.8px"><br>
</span></div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">You might
try it. And I rest my case here, Kim!</span></div>
<div><span style="color:rgb(80,0,80);font-size:12.8px"><br>
</span></div>
<div><span style="color:rgb(80,0,80);font-size:12.8px">Zoran</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Jul 20, 2016 at 6:52 AM, 김유석 <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:poplinux0@gmail.com" target="_blank">poplinux0@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Dear Sir. <br>
<br>
I'm understand your worry.<br>
<br>
My phase is develop the raw level API for gpio control.<br>
SW I2C is will use the raw level API. SW I2C is will
implementation.<br>
<br>
I was set the SC_USE_SEL, and SC_IO_SEL. correctly.<br>
<br>
And I already check the some function.<br>
1. outmode => is OK.<br>
If i set the HIGH on 12, 13, 14. then i can saw
the HIGH status using ocilloscope.<br>
If i set the LOW on 12, 13, 14. then i can saw the
LOW status using ocilloscope.<br>
2. input mode => is OK.<br>
If i assign the 3.3V to 12, 13, 14. then i can
read the SC_GP_LVL(0x7000).<br>
If i assign the 0V to 12, 13, 14. then i can read
the SC_GP_LVL(0x00)<br>
<br>
But just one function is fail.<br>
<br>
step 1. set the output mode. => is success<br>
step 2. set the level. => is success<br>
step 3. read the current config of SC_GP_LVL => is
fail.<br>
if if write 0x7000 to SC_GP_LVL, I want to read
the value 0x7000 from SC_GP_LVL. But i can't<br>
<br>
Thank you. <br>
<br>
<br>
<br>
<br>
2016-07-19 오후 9:12에 Zoran Stojsavljevic 이(가) 쓴 글:<br>
</div>
<div>
<div class="h5">
<blockquote type="cite">
<div dir="ltr">Hey Kim,
<div><br>
</div>
<div>You have forced me myself to read the manual
(chapter 25, C2000 Data Sheet). I was really
wondering... So I decided to spend some time and
read it myself (anyway, I have some time, albeit
I do some other stuff). ;-)</div>
<div><br>
</div>
<div>There is description of two power domains
there, which I/O are using in order to drive
customer I/O wishes. Two of them are: Core Well
and SUS Well. You are using Core Well GPIOs,
namely they are described in Ch. 25.3.1:</div>
<div>Choosing the native Signal Mode or Customer
GPIO Mode.</div>
<div><br>
</div>
<div><img
src="cid:part2.8A23B9A2.E00EF89B@gmail.com"
alt="Inline image 1" height="459" width="473"><br>
</div>
<div> </div>
<div>Questions here: did you set properly
register: SC_USE_SEL? Your bits 12/13/14 should
be in this register 1s (x111 xxxx xxxx xxxx
binary), and you need to set also properly
SC_IO_SEL register (them to be outputs). I am
now looking into your code, and it seems you did
it correctly (three OUT values):</div>
<div><span style="font-size:12.8px">
GPIO_SC_USE_SEL : 7000</span><br
style="font-size:12.8px">
<span style="font-size:12.8px">
GPIO_SC_IO_SEL : 0</span><br
style="font-size:12.8px">
<span style="font-size:12.8px">
GPIO_SC_GP_LVL : 0</span><br>
</div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">Then you
output your OUT values. Hmmmmmm... Considering
I2C, you inevitable should read some INPUT
values?! Which pins these are? You should have
from master (your C2000) to supply CLK and
OUT, but you also need to read IN values...
Don't you???</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">I do NOT see
input from I2C slave device... Any thoughts
(any ideas)?</span><br>
</div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">Zoran</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Jul 18, 2016 at
7:20 AM, 김유석 <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:poplinux0@gmail.com"
target="_blank">poplinux0@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Dear Sir.<br>
<br>
I was test with by your advise. But
SC_GP_LVL is always read 0x00<br>
<br>
source code & result is see below.<br>
<br>
<table border="1" cellpadding="2"
cellspacing="2" width="100%">
<tbody>
<tr>
<td valign="top"> u32
read_gpio_level(const struct
soc_gpio_map *gpio)<br>
{<br>
<br>
u16 gpiobase
__attribute__((unused)) =
pci_read_config16(SOC_LPC_DEV,
GBASE) & ~0xf;<br>
<br>
printk(BIOS_DEBUG, "%s() :
Start\n", __FUNCTION__);<br>
printk(BIOS_DEBUG, "
GPIO_SC_USE_SEL : 0x%x\n",
inl(gpiobase + GPIO_SC_USE_SEL));<br>
printk(BIOS_DEBUG, "
GPIO_SC_IO_SEL : 0x%x\n",
inl(gpiobase + GPIO_SC_IO_SEL));<br>
printk(BIOS_DEBUG, "
GPIO_SC_GP_LVL : 0x%x\n",
inl(gpiobase + GPIO_SC_GP_LVL));<br>
printk(BIOS_DEBUG, "%s() :
End\n\n", __FUNCTION__);<br>
<br>
return 0;<br>
}<br>
<br>
int set_gpio_level(const struct
soc_gpio_map *gpio,<br>
const int
num,<br>
const int
lvl)<br>
{<br>
u16 gpiobase
__attribute__((unused)) =
pci_read_config16(SOC_LPC_DEV,
GBASE) & ~0xf;<br>
u32 GPIO = 0;<br>
<br>
GPIO = setBit(GPIO, num);<br>
<br>
printk(BIOS_DEBUG, "%s() :
GPIO set value 0x%x\n",
__FUNCTION__, GPIO);<br>
outl(GPIO, gpiobase +
GPIO_SC_GP_LVL);<br>
<br>
return 0;<br>
}<br>
<br>
<br>
void
early_mainboard_romstage_entry(void)<br>
{<br>
setup_soc_gpios(&gpio_map);<br>
set_gpio_level(&gpio_map,
12, 1);<br>
mdelay(500);<br>
read_gpio_level(&gpio_map);<br>
<br>
set_gpio_level(&gpio_map,
13, 1);<br>
mdelay(500);<br>
read_gpio_level(&gpio_map);<br>
<br>
set_gpio_level(&gpio_map,
14, 1);<br>
mdelay(500);<br>
read_gpio_level(&gpio_map);<br>
};<br>
<br>
<br>
==================================================================================<br>
coreboot-NexG-59a9b0a6 Mon Jul
18 05:09:30 UTC 2016 romstage
starting...<br>
set_gpio_level() : GPIO set
value 0x1000<br>
read_gpio_level() : Start<br>
GPIO_SC_USE_SEL : 7000<br>
GPIO_SC_IO_SEL : 0<br>
GPIO_SC_GP_LVL : 0<br>
read_gpio_level() : End<br>
<br>
set_gpio_level() : GPIO set
value 0x2000<br>
read_gpio_level() : Start<br>
GPIO_SC_USE_SEL : 7000<br>
GPIO_SC_IO_SEL : 0<br>
GPIO_SC_GP_LVL : 0<br>
read_gpio_level() : End<br>
<br>
set_gpio_level() : GPIO set
value 0x4000<br>
read_gpio_level() : Start<br>
GPIO_SC_USE_SEL : 7000<br>
GPIO_SC_IO_SEL : 0<br>
GPIO_SC_GP_LVL : 0<br>
read_gpio_level() : End<br>
<br>
<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
And I was re-view the DS of C2000. <br>
<br>
But DS is said to me that SC_GP_LVL is WR
register.<br>
<br>
<br>
<br>
Please help me.<br>
<br>
Thank you. <br>
<br>
<br>
<br>
<br>
2016-07-13 오후 4:40에 Zoran Stojsavljevic
이(가) 쓴 글:<br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div><b style="font-size:12.8px"><u><font
face="굴림체">> When write
0x7000 write to SC_GP_LVL,
Can read the 0x00 from
SC_GP_LVL. everytime.</font></u></b><br>
</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Please, try
to do the following exercise:</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">[1] WR
0x1000 to <span
style="font-size:12.8px"><font
face="굴림체">SC_GP_LVL, then RD
the value out of it: what it
is?</font></span></div>
<div class="gmail_extra">[2] WR
0x2000 to <span
style="font-size:12.8px"><font
face="굴림체">SC_GP_LVL, then RD
the value out of it: what it
is?</font></span><span
style="font-size:12.8px"><font
face="굴림체"><br>
</font></span></div>
<div class="gmail_extra">[3] WR
0x4000 to <span
style="font-size:12.8px"><font
face="굴림체">SC_GP_LVL, then RD
the value out of it: what it
is?</font></span></div>
<div class="gmail_extra"><span
style="font-size:12.8px"><font
face="굴림체"><br>
</font></span></div>
<div class="gmail_extra"><span
style="font-size:12.8px"><font
face="굴림체">If you have all
0x0, most likely it does mean
that Rangeley's </font></span><span
style="font-family:굴림체;font-size:12.8px">SC_GP_LVL register isd WR ONLY
(when you read it, all 0s).</span></div>
<div class="gmail_extra"><span
style="font-family:굴림체;font-size:12.8px"><br>
</span></div>
<div class="gmail_extra"><span
style="font-family:굴림체;font-size:12.8px">To
ver</span><span
style="font-family:굴림체;font-size:12.8px">ify
this, you should fetch the
following document:</span></div>
<div class="gmail_extra"><font
face="굴림체"><span
style="font-size:12.8px"><a
moz-do-not-send="true"
href="http://www.intel.com/content/www/us/en/processors/atom/atom-c2000-microserver-datasheet.html"
target="_blank">http://www.intel.com/content/www/us/en/processors/atom/atom-c2000-microserver-datasheet.html</a></span></font><br>
</div>
<div class="gmail_extra"><font
face="굴림체"><span
style="font-size:12.8px"><br>
</span></font></div>
<div class="gmail_extra"><font
face="굴림체"><span
style="font-size:12.8px">And
read Chapter 25 - General
Purpose I/O (GPIO).</span></font></div>
<div class="gmail_extra"><span
style="font-family:굴림체;font-size:12.8px"><br>
</span></div>
<div class="gmail_extra"><span
style="font-family:굴림체;font-size:12.8px">Best
Regards,</span></div>
<div class="gmail_extra"><span
style="font-family:굴림체;font-size:12.8px">Zoran </span></div>
<div class="gmail_extra"><font
face="굴림체"><span
style="font-size:12.8px"><br>
</span></font>
<div class="gmail_quote">On Wed,
Jul 13, 2016 at 6:39 AM, 김유석 <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:poplinux0@gmail.com"
target="_blank">poplinux0@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"
text="#000000">
<p><font face="굴림체">Dear
Sir. <br>
</font></p>
<p><font face="굴림체"><br>
I want to control the
GPIO pin that pin number
is 12, 13, 14</font></p>
<p><font face="굴림체"><br>
DataSheet(P 1909) and
coreboot source
code(src/southbridge/intel/fsp_rangeley/gpio.c, gpio.h) is said to me
that "It is very easy"</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">If i
want to set the HIGH to
12, 13, 14</font></p>
<p><font face="굴림체">Just
setup the some register,
is see below.<br>
</font></p>
<p><font face="굴림체">
SC_USE_SEL =
0x7000(b0111 0000 0000
0000)<br>
</font></p>
<p><font face="굴림체"> Is
mean, the 12, 13, 14 is
config to GPIO
mode.(enable GPIO)<br>
</font></p>
<p><font face="굴림체">
SC_IO_SEL = 0x00(b0000
0000 0000 0000)<br>
</font></p>
<p><font face="굴림체"> Is
mean, the 12, 13, 14 is
output mode<br>
</font></p>
<p><font face="굴림체">
SC_GP_LVL = 0x7000</font><font
face="굴림체">(b0111 0000
0000 0000)</font></p>
<p><font face="굴림체"> Is
mean, the 12, 13, 14 is
set to HIGH level(1)</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">src/southbridge/intel/fsp_rangeley/gpio.h</font></p>
<p><font face="굴림체"> /*
Core GPIO */<br>
const struct soc_gpio
soc_gpio_mode = {<br>
.gpio12 =
GPIO_MODE_GPIO, /* Board
ID GPIO */<br>
.gpio13 =
GPIO_MODE_GPIO, /* Board
ID GPIO */<br>
.gpio14 =
GPIO_MODE_GPIO, /* Board
ID GPIO */<br>
};</font></p>
<p><font face="굴림체"> const
struct soc_gpio
soc_gpio_direction = {<br>
.gpio12 =
GPIO_DIR_OUTPUT,<br>
.gpio13 =
GPIO_DIR_OUTPUT,<br>
.gpio14 =
GPIO_DIR_OUTPUT,<br>
};<br>
</font></p>
<p><font face="굴림체"> const
struct soc_gpio
soc_gpio_level = {<br>
.gpio12 =
GPIO_LEVEL_HIGH,<br>
.gpio13 =
GPIO_LEVEL_HIGH,<br>
.gpio14 =
GPIO_LEVEL_HIGH,<br>
};<br>
<br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">Yes, It
is perfectley running.</font></p>
<p><font face="굴림체">The 12,
13, 14 PIN is goto
active-HIGH.(I was check
this pin use by
oscilloscope.)<br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">And I'm
try to read the
SC_GP_LVL register for
check current
status/config of gpio
pins</font></p>
<p><font face="굴림체">I was <b>respected</b>
the read value is <b>0x7000</b>,
because i was writed the
<b>0x7000</b> to
SC_GP_LVL.</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">But,
every time readed the <b>0x00</b>
from SC_GP_LVL register.</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><u><font face="굴림체">When
write 0x7000 write to
SC_USE_SEL, Can read
the 0x7000 from
SC_USE_SEL.</font></u></p>
<p><u><font face="굴림체">When
write 0x00 write to
SC_IO_SEL, Can read
the 0x00 from
SC_IO_SEL.</font></u></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">But,</font></p>
<p><br>
<b><u><font face="굴림체">When
write 0x7000 write
to SC_GP_LVL, Can
read the 0x00 from
SC_GP_LVL.
everytime.</font></u></b></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">I don't
understand this
sistuation.<br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">Please
advise to me. <br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체">Thank
you. </font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
<p><font face="굴림체"><br>
</font></p>
</div>
<br>
--<br>
coreboot mailing list: <a
moz-do-not-send="true"
href="mailto:coreboot@coreboot.org"
target="_blank">coreboot@coreboot.org</a><br>
<a moz-do-not-send="true"
href="https://www.coreboot.org/mailman/listinfo/coreboot"
rel="noreferrer"
target="_blank">https://www.coreboot.org/mailman/listinfo/coreboot</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>