|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 e( {+ R! f& j5 \+ Q* f#include <linux/init.h>6 d, _+ N* D: c8 c* i6 d2 i
#include <linux/module.h>
$ l C1 Z8 ~6 e#include <linux/kernel.h>, h2 B. ?! ? c8 ^3 q
#include <linux/types.h> ~. q8 k! P$ l# }! ?- o
#include <linux/gpio.h>
" j# V. s. Q, V* Q7 [9 m* J#include <linux/leds.h>( H% v; y$ K) K" ]
#include <linux/platform_device.h>
1 }+ t4 E( k' b& Q& N- n! n6 w/ d( U2 b- |3 Z
#include <asm/mach-types.h>1 m' V1 o; a1 X: T# I6 B% ~) K5 z
#include <asm/mach/arch.h>
* C6 r w, u+ P6 s4 O* h% K#include <mach/da8xx.h>$ d$ d' U( h2 M/ }7 W: Y( o+ N
#include <mach/mux.h>
0 E( d6 U J$ D7 V2 A0 _/ _% c2 Y3 H- a" K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 b$ r/ ^6 U' \4 j* J# ~. o5 Z( N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 [ U, G; p& @+ `) O# ?+ q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( b0 _ h* \; r) g4 U) i0 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ v2 [, B+ L$ x- z5 M
& F9 P! M) N: J% n/* assign the tl som board LED-GPIOs*/- z3 ?! C" ~! K0 N
static const short da850_evm_tl_user_led_pins[] = {
. I5 c6 h& H/ S' r" T /* These pins are definition at <mach/mux.h> file */
3 s8 i3 N! i4 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% j* J% `! p/ s5 u0 }; v! \# @- i
-1
7 I |+ J5 {0 m( \3 H' J& s};( R* i p/ k) |1 z/ f
$ m7 k$ x+ ~8 P0 dstatic struct gpio_led da850_evm_tl_leds[] = {
4 j$ W8 o( x/ X% W0 E- r* S! C$ Y% ~ {
/ a0 ?( T: O7 o6 j' ? .active_low = 0,- g. {1 e8 q8 J0 t4 ^' V
.gpio = DA850_USER_LED0,* E# o# v) |! z$ x. T( d+ I% ~
.name = "user_led0",9 y0 C/ z: T# T# k
.default_trigger = "default-on",7 s: C% j) L7 K& p, j
},' G3 ]2 A: t/ a
{* Y4 e* N/ i( ?$ y
.active_low = 0,: W' x$ j6 L( q2 \8 m8 p" X# P! m
.gpio = DA850_USER_LED1,7 X: t% J, n$ M: f
.name = "user_led1",( @! ]- ~3 h1 d( f2 a
.default_trigger = "default-on",
) `/ i( C O" R! n },' ^6 g+ E; m' |
{; H. v% S% B/ ~- C: A# r
.active_low = 0, @( ]% x7 V7 n! R- E: @3 e
.gpio = DA850_USER_LED2,+ U L/ B: U: x4 W, e
.name = "user_led2",
% U0 x4 l! t& h {' T- \) i .default_trigger = "default-on",
5 |' [5 m6 B' p# Z9 ?) p; R2 R1 ` },
. M/ g- e; y+ ] {. m7 {! A8 q9 N. C" ], l5 u
.active_low = 0,
5 Q# F& C2 M$ d6 C .gpio = DA850_USER_LED3,
/ A! ?! q' w$ y' L) t. j4 l) [: G, [ .name = "user_led3",$ T: [4 U7 C2 l: d( V5 m, o
.default_trigger = "default-on",% Q3 K2 ^ V1 k' W3 `
},
: P( E$ f/ @& c7 w! A2 m};
& y; c$ g' B6 [4 U
@! `6 N# I0 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
V0 a. K8 {1 D8 U; Z .leds = da850_evm_tl_leds,' E; Z5 b {* E- c: y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% W0 J! l% C6 L% s" l};& I$ d) j$ L% S( Z( e8 w( {% p
( s! V: u" Y8 e
static void led_dev_release(struct device *dev)/ s7 A: d$ F$ @( Y) K( m
{, h( }5 l6 H1 A
};
' g/ g& J1 f. K8 Z
* C; J. X- \7 Zstatic struct platform_device da850_evm_tl_leds_device = {# M! x3 s+ O9 |
.name = "leds-gpio",# o* f! [2 [; D
.id = 1,; r) K, G& }( O! Y9 a
.dev = {* n. a3 g- `% Q% D
.platform_data = &da850_evm_tl_leds_pdata,
* G% j/ n8 k4 p% X+ W .release = led_dev_release,
; b$ {6 s4 c/ K9 b" A }( l! t" H; E0 `2 M
};
" {& E( s2 d* ]; b$ Q |3 `/ T
' a* G+ w# v% }9 Z' j/ E" c. Dstatic int __init led_platform_init(void)! C0 \! \9 D/ K. c4 |3 N0 H! G
{8 z8 x* K; a% F& s- P+ W2 T
int ret;
3 q" l, k, Z9 _$ Q4 M#if 06 ~- L. D% o/ C+ h0 U" ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Y( n$ \2 F, s" U
if (ret)3 D+ @8 y$ `) s) M# O7 P, W, y: {" p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 v, \- h8 {( U, X5 A "%d\n", ret);
0 t, Q: s6 M/ s#endif% Q1 [0 L* {1 j2 {5 e
ret = platform_device_register(&da850_evm_tl_leds_device);, Q$ z$ G9 V- N! `' A
if (ret)
. @9 _, H6 v+ D Z. Q+ M% ?6 Z# t% Y pr_warning("Could not register som GPIO expander LEDS");
5 v5 A2 j7 }' b/ [6 F8 d; ]4 P else
* }3 h) o& c1 P2 @; K( `5 z printk(KERN_INFO "LED register sucessful!\n");
( X4 r5 x+ x, R- m7 k2 M9 t5 H' X% T
return ret;
* [9 y; U/ @% {8 I" N6 Q}1 m1 N& Z7 t$ B! B5 }- A8 y
8 U. Y- W/ k3 S
static void __exit led_platform_exit(void); m3 ]2 X! }3 l8 `
{
% O% a+ L) Z2 N" j1 a platform_device_unregister(&da850_evm_tl_leds_device);
0 M8 h% U( u& J! r
8 B& v# D/ J7 E% ?' n7 W6 _& `4 f" W printk(KERN_INFO "LED unregister!\n");
% \) C' _7 P8 ?( f: O8 A' u}! N3 B' n4 b6 W, g+ d
' T j9 u) v4 V( I" U6 u+ e) ?module_init(led_platform_init);
) {4 w8 s. K: L6 Ymodule_exit(led_platform_exit);
5 j) R) `+ M2 `0 ^8 Z7 g
/ N$ a/ F$ T2 w* r( W+ UMODULE_DESCRIPTION("Led platform driver");& ~' }8 c* E5 |% g0 L& u
MODULE_AUTHOR("Tronlong");
0 N2 w: B0 ]$ {: `- P9 KMODULE_LICENSE("GPL");
; N7 E6 n% ~' W- r& N0 H
2 P- j# @+ D/ A6 V" D9 ?; D/ H C |
|