|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ {3 A# C2 f" ?# u% ?#include <linux/init.h>9 F/ X+ o1 H: o! j6 `0 ~/ l
#include <linux/module.h>4 k* b' P/ U+ x% [- y
#include <linux/kernel.h>
7 L4 B' E1 H4 k8 D& R#include <linux/types.h>% q! N6 V! k! ^7 T8 a
#include <linux/gpio.h>+ V+ N, N* f9 y! w) t' I
#include <linux/leds.h>
) r7 h7 H3 _: S3 e#include <linux/platform_device.h>" [# q. X) i- u& V% o( p( c; |6 c7 Y/ p
* {9 Q n8 s8 U5 g% n" `/ J% H#include <asm/mach-types.h>
* W; P) J2 Y& B5 _( m8 S#include <asm/mach/arch.h>; G6 R# Q. @+ n* y: S: [/ P
#include <mach/da8xx.h>5 `9 A( q: e/ w/ d
#include <mach/mux.h>) ?" x5 l* i' q Z* U g
1 ~9 i0 V' R+ g( \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 G, f% K3 }5 m$ Q3 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ H1 P! r' G( J! l! s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! U+ O0 }7 F; B: J4 U. h6 ~+ s8 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! }! P( p" a5 b' U# q
* s- Q9 u( c1 F5 Q1 [4 ~/* assign the tl som board LED-GPIOs*/* F3 V( `& T" _$ e
static const short da850_evm_tl_user_led_pins[] = {
8 e6 s( O% k! [4 t3 r /* These pins are definition at <mach/mux.h> file */
4 \+ W3 h7 K/ Y" a1 [3 ^ a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 P4 S. {- \& H ?
-1
% S# R+ e4 {& o3 P# [+ a};/ S. T# o5 U; y) `9 [
- c9 N; O3 j% K* i( q
static struct gpio_led da850_evm_tl_leds[] = {
% b( n2 C7 e/ k, P2 S9 J j; N {( s, m- M* j: d0 c8 D# f
.active_low = 0,3 V" }+ h1 R* O0 A- b$ w
.gpio = DA850_USER_LED0,
0 ?# c' P2 e# b: R/ B .name = "user_led0",
5 I! y0 k2 E% Y4 P .default_trigger = "default-on",
9 M6 Q$ X0 P8 k },& y- y! P) t" w! F: i" d( |4 M
{
V/ z. z2 P5 D( W) c4 b .active_low = 0,6 {1 h! i3 ]3 ?" g
.gpio = DA850_USER_LED1,4 l% {* y& G8 S
.name = "user_led1",
& Y9 a3 j2 q3 K3 P' g( f+ b! @; ~" v .default_trigger = "default-on",4 }$ r ^+ H! |& R# n3 m
}, I, e4 N: Z6 j7 Z' H( ~
{
7 W; w. o1 g9 ?& m) L6 d .active_low = 0,7 ^. Q; R6 Q2 t# a$ t% o
.gpio = DA850_USER_LED2,9 d9 p, c( X, J$ F4 `4 E
.name = "user_led2",4 p8 y! c# y% e$ A( l( m
.default_trigger = "default-on"," f6 O3 V, s/ k+ {$ W
},/ f8 h8 @* q. E0 F2 U, B
{1 P, z1 K5 |% }# }1 e" b* N4 T$ j
.active_low = 0,% |8 S! z$ t4 Y# J) J8 w
.gpio = DA850_USER_LED3,
" D1 M( Q2 O! p7 b9 k6 _ .name = "user_led3",
% g8 ?0 E6 D& T( } .default_trigger = "default-on",
( ?! B, n2 V2 t },
& U% d8 d, f: V};% d+ ?2 [4 r# i' r* s
# @5 s$ @. v* A+ \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. l) S& d2 h3 N( b7 d, d .leds = da850_evm_tl_leds,
# Z" a# y8 w# R3 w- i0 w; F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ _2 l" C7 R& e; j% z2 Y};7 p6 u8 f% F# c9 `7 ]- z
1 X4 f6 `/ T4 i
static void led_dev_release(struct device *dev)+ I( ?/ \9 f" E' M
{
, f" t) [ R: [7 P9 F3 N* R# k};
& q8 g0 h2 h" p$ }! S. N$ ]! q6 P5 I o. `0 d
static struct platform_device da850_evm_tl_leds_device = {
, r7 L: i$ o+ Q t# y .name = "leds-gpio",3 Y9 t! G A9 l; r- A3 D
.id = 1,
3 }2 P4 e8 U) o& u7 |7 t .dev = {
I1 @8 {1 H2 _" N& K8 o$ L .platform_data = &da850_evm_tl_leds_pdata,9 T) V# L9 Y; s. i2 D
.release = led_dev_release,
* E/ Z7 e8 F; s }
" |" p% O; H& D% X: N! T5 \) p5 C};
! W& M) n7 ^1 @5 j: q
- ? [5 M. D* X1 s3 p" Tstatic int __init led_platform_init(void)
( B& ^$ d Q! B{" b" b9 i4 q* l/ B& Z4 P$ {6 z
int ret;
2 b5 O) Z$ y, @1 {8 b#if 0
( k8 B# X4 J+ O# W2 G; a1 ^8 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; E+ U- d" [9 D if (ret)
& [5 W% G4 S9 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! d: N/ t2 O* |5 ^4 d; F- \ "%d\n", ret);
9 ^8 s) Z. ^) N#endif) w$ D- `" n" U& g3 ?
ret = platform_device_register(&da850_evm_tl_leds_device);0 _* O9 {; x8 k
if (ret)
6 ~; v6 ]9 i3 ?2 u pr_warning("Could not register som GPIO expander LEDS");
" W4 C6 e" Y4 q8 Z$ n5 s& ^* z else* W$ j, Q2 x* e+ s4 ?
printk(KERN_INFO "LED register sucessful!\n");4 ?. p& T0 o1 H6 Z/ Y
8 C |5 ^1 ?3 f! n) r8 j/ }: q5 t. w
return ret;
. v! a, \) ~3 Q0 T! `. @0 { o}9 V, U4 r% L$ I6 o( W9 N. L, g
7 Y4 S9 U. }2 L- [7 w2 |static void __exit led_platform_exit(void)
4 y" X) M; s) l" u8 X7 ~2 d{( L" r9 K; e; L) `
platform_device_unregister(&da850_evm_tl_leds_device);( e8 w F6 \% {1 z) C+ Z7 V
8 x( y% i1 V" \4 O5 j- \4 f) V
printk(KERN_INFO "LED unregister!\n");
$ ?- ]0 I/ J( j+ ]' s}
Y* \' j. g8 \4 K, e) D2 x4 E" v- n3 [" U" p
module_init(led_platform_init);0 a: a: |8 M1 \, I. G7 x
module_exit(led_platform_exit);. {( a7 A6 W. t4 g. \1 E
- Z- F8 l. E# `+ X k( t
MODULE_DESCRIPTION("Led platform driver");) B0 ~( u9 p; b" n9 Y
MODULE_AUTHOR("Tronlong");
* U7 y4 x6 r# Y# ^0 G, c/ u5 }MODULE_LICENSE("GPL");
2 \! F1 Z# P- W. ]5 N6 }' p$ b$ S" }4 U- V8 Z6 n
|
|