|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' U- l5 H4 o* o; J#include <linux/init.h>. t6 N1 B* W4 g* e# d- k* o
#include <linux/module.h>
, O1 J/ m1 h( s3 f) C$ ], _#include <linux/kernel.h>1 ^8 B9 Q0 K$ A* h4 v
#include <linux/types.h>6 N; u2 R3 q2 x& d9 N1 p
#include <linux/gpio.h>
4 w" }4 {0 G4 r* @" ^: X3 H#include <linux/leds.h>
5 } p4 g% q; I- j* W Z9 Z" ~#include <linux/platform_device.h>. B: z& g. J( I5 M" Y1 u. |5 @* [
8 F2 @- w' n) t- @0 X" x Y: p6 t
#include <asm/mach-types.h>7 p8 U* l: j8 k5 e9 M6 c& r
#include <asm/mach/arch.h>
; @$ ~* C$ ^0 v* J#include <mach/da8xx.h>
9 N5 @; I* F- f5 J" w#include <mach/mux.h>; d5 j: }/ @' U5 g
2 I- M/ s' h: C( @5 q6 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( d: \$ l) i+ ~9 x6 @( T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# [& N3 ?% S( v9 {! T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 J0 `( b a! J9 x) h, M) h$ a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 a: l. V- a# K7 Q* F" P8 `+ S
* A4 s9 K7 S. T! g$ }; S
/* assign the tl som board LED-GPIOs*/
: d, b: D1 {" L/ v) K* ~static const short da850_evm_tl_user_led_pins[] = {5 ]5 Y f, e/ C) l# R6 o6 P
/* These pins are definition at <mach/mux.h> file *// p4 ^- C" Y' k6 Z" @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! s, t, P7 a2 ^( q U$ ~ -1" q7 q1 a, U3 Q1 J0 w7 i/ g
};
: N- \. E( @# ~- {! h7 y3 L% u0 x8 Z% E
static struct gpio_led da850_evm_tl_leds[] = {
+ O. r- a9 }( L+ J$ q5 S5 Y5 R {& ~/ a0 {( c2 ^& S# o& d
.active_low = 0,
0 z* N# d, [" X, S5 A5 f .gpio = DA850_USER_LED0,
2 X, @% ?1 A! x. E5 y; E .name = "user_led0",
1 K, H0 { R/ g9 N" I2 f; K% _ .default_trigger = "default-on",
6 ^. V3 {- [( n1 M: T },4 d8 U( \1 q& ]. y& T
{
# S# b4 b/ V* z0 T" D3 c9 U .active_low = 0,0 s$ o8 F! v( q! G
.gpio = DA850_USER_LED1,/ K5 Y& L) x3 X0 A# U4 v
.name = "user_led1",
3 z' G9 z5 R1 p: E9 C. @: { .default_trigger = "default-on",
7 }7 N* P$ ~- O/ V },
6 }( i( g% X5 V) C( r {
" |" x# g" t A9 g .active_low = 0,
5 I! v$ ?% n$ ^9 Y( O, U5 M* i .gpio = DA850_USER_LED2,
. o9 j, K. j: V .name = "user_led2",
% e# F4 ]0 w/ q6 T7 }3 _4 g .default_trigger = "default-on",9 E- ?2 K% f! Q) K
},
1 a9 G& R9 U2 k {0 _" Q1 P/ {5 N' a
.active_low = 0,
- o! z& c6 ]! O! V! ~) k .gpio = DA850_USER_LED3,
$ l+ O9 o; j! q( e( V .name = "user_led3",
( E, G! n3 I4 j4 U/ A2 p .default_trigger = "default-on"," j, r! b& f: @" Z
},
/ d) ^% r: l, w9 v9 v/ f};
0 |" k( b2 T; r; r" }) l0 Q
( L& d2 a3 N7 f! Y! G5 ?, f# Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! x9 H2 n3 o3 N" [# s .leds = da850_evm_tl_leds,: O1 L7 ^- a7 D" D( f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 z6 X' L6 O s' U& N& z
};
( l) H0 |! S J
5 _4 i u0 }2 D% Dstatic void led_dev_release(struct device *dev)
2 g# n& o$ h- O1 _- s' C{( T- b$ ?! ~$ u( s, e8 O/ J
};
2 u% d+ O1 w1 y. U }! h& S8 O- I6 \4 a. J0 t( m( [" I3 k
static struct platform_device da850_evm_tl_leds_device = {
; a4 Z" |! W" H. w .name = "leds-gpio",: D% N. q B/ N3 Z+ w
.id = 1,; d' t0 b, b* E) N2 Z# y( @" P
.dev = {
% U! j9 [$ I9 o9 S .platform_data = &da850_evm_tl_leds_pdata,
i8 e" Y- j' h8 `# @ .release = led_dev_release,
4 _5 |- e% X" k! m1 z) V }
" }+ }' [. M6 J; E4 T! |, N+ h0 j};
% Q$ ~9 I# R3 |% ]) K3 y' @
* u4 l: p& s8 ]! Sstatic int __init led_platform_init(void)
# _5 a# a5 H" g- [2 C" z m$ j! K{
& M4 i2 I# I e* f int ret;
: Y& {( l# y' |4 q% p+ Q" ^#if 00 z- Z: v! y4 [4 p$ _5 Z2 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ p+ D4 K: J+ r" Q% h! W if (ret)) l0 D4 i# Z/ F& Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 \4 |3 A: p4 B5 i3 | "%d\n", ret);# f! w5 D, z$ y" F7 O: ?
#endif
3 H! I1 N% m; \" G6 i* \4 d" A, u; z ret = platform_device_register(&da850_evm_tl_leds_device);0 V# w3 ]& Y+ C( i1 Q4 s
if (ret)
3 B/ a# S7 N- W; y2 H# L pr_warning("Could not register som GPIO expander LEDS");( M4 |0 b) G+ T0 d ^/ |
else
& e6 o! T* k. y" C printk(KERN_INFO "LED register sucessful!\n");
- ~& v( Y) Z7 k# a$ Q) A3 {' A! T0 Y6 q4 G5 X' R- m
return ret;
: u' o. |# A) d A}: ^" l8 Z. t! d: _" P
9 q/ H( x; P: U/ A7 O: o d
static void __exit led_platform_exit(void)/ v( I: ^- i; A8 I6 b
{0 R# b B* {, y
platform_device_unregister(&da850_evm_tl_leds_device);
' v$ k+ G r/ H4 A1 V9 S- Q: t. E* m
printk(KERN_INFO "LED unregister!\n");1 U$ j! F9 v* Y9 \4 W
}
; J6 C) ]# i. ~4 J% [
2 a* U2 v9 @) w9 r2 [module_init(led_platform_init);
6 W$ P' O# W& ~% ]* @# Zmodule_exit(led_platform_exit);4 |0 p% |1 M% C1 {. c
8 r4 @, w) Q: j) W/ ^MODULE_DESCRIPTION("Led platform driver");- R4 b, z2 n; W
MODULE_AUTHOR("Tronlong");
" y1 s0 u7 D3 M ^: jMODULE_LICENSE("GPL");3 x1 V g2 |1 v j9 @6 Y& F
! x0 {2 W- Y$ l0 h' Z
|
|